/* ==========================================================
   CRM Wilza Gracielle Advocacia
   Sistema visual: luxo discreto.
   Sidebar preto institucional, área de trabalho clara e quente,
   dourado champanhe usado apenas como acento.
   ========================================================== */

/* ----------------------------------------------------------
   1. DESIGN TOKENS
   Toda cor, raio, sombra e espaçamento do sistema nasce aqui.
   ---------------------------------------------------------- */
:root {
  /* Superfícies */
  --bg-app:        #F7F5F1;
  --bg-subtle:     #F3F0EA;
  --bg-card:       #FFFFFF;
  --bg-card-alt:   #FCFBF8;
  --bg-sidebar:    #151615;
  --bg-hover:      #F3F0EA;

  /* Texto */
  --text-primary:   #181817;
  --text-secondary: #69665F;
  --text-muted:     #747068;   /* era #98938B: subia so 2,8:1 de contraste */
  --text-on-dark:   #F5F2EB;

  /* Bordas */
  --border-default: #E6E1D8;
  --border-subtle:  #EEEAE3;

  /* Marca */
  --black:      #151615;
  --black-soft: #252623;
  --gold:       #B39155;
  --gold-dark:  #7D6237;       /* era #866A3D: 4,39:1 sobre o gold-bg */
  --gold-light: #D6C29B;
  --gold-bg:    #F4EEE2;

  /* Estados. O texto usa o tom escuro, o fundo o tom claro. */
  --danger:      #C94B4B;
  --danger-text: #B94343;
  --danger-bg:   #FDE9E8;
  --danger-line: #F1D3D0;

  --success:      #557A66;
  --success-text: #3E7150;
  --success-bg:   #EAF5EE;

  --info-text: #496B7D;
  --info-bg:   #E8F0F4;

  --warn-text: #7F5F28;        /* era #8A682D: 4,22:1 no badge */
  --warn-bg:   #F3E8D2;

  /* Tipografia */
  --sans:  'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --brand: 'Cormorant Garamond', Georgia, serif;

  /* Raios */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;

  /* Sombras, sempre discretas */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.03);
  --shadow-md: 0 1px 2px rgba(0,0,0,.03), 0 6px 18px rgba(0,0,0,.025);
  --shadow-pop: 0 4px 12px rgba(0,0,0,.06), 0 16px 40px rgba(0,0,0,.08);

  /* Escala de espaçamento, múltiplos de 4 */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px;

  --sidebar-w: 252px;

  /* ---- Aliases dos nomes antigos ----
     As views trazem style inline apontando para estes nomes.
     Mantê-los apontando para o sistema novo evita estilo duplicado
     e faz toda a interface migrar de uma vez. */
  --bg:            var(--bg-app);
  --bg-panel:      var(--bg-app);
  --bg-card-hover: var(--bg-card-alt);
  --bg-input:      var(--bg-card);
  --text:          var(--text-primary);
  --text-dim:      var(--text-muted);
  --border:        var(--border-default);
  --border-soft:   var(--border-subtle);
  --gold-faint:    var(--gold-bg);
  --gold-dim:      var(--border-default);
  --red:           var(--danger-text);
  --red-soft:      var(--danger-bg);
  --green:         var(--success-text);
  --green-soft:    var(--success-bg);
  --blue:          var(--info-text);
  --blue-soft:     var(--info-bg);
  --amber:         var(--warn-text);
  --amber-soft:    var(--warn-bg);
  --radius:        var(--radius-lg);
  --serif:         var(--sans);
}

/* ----------------------------------------------------------
   2. BASE
   ---------------------------------------------------------- */
* { box-sizing: border-box; }

/* Trava de segurança: SVG sem largura definida assume 300x150px
   e estoura o layout. Todo ícone nasce com 18px. */
svg { width: 18px; height: 18px; flex-shrink: 0; }

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { font-family: var(--sans); margin: 0; line-height: 1.25; letter-spacing: -.011em; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: 4px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #DCD6CA; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #C8C1B2; background-clip: content-box; }

/* ----------------------------------------------------------
   3. LOGIN
   ---------------------------------------------------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  background: var(--bg-app);
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-10) var(--sp-8);
  box-shadow: var(--shadow-md);
}
.login-card .brand { text-align: center; margin-bottom: var(--sp-8); }
/* Aqui cabe a marca real do escritório: a moldura tem espaço para ser
   lida. Na sidebar, a 46px, ela vira um borrão e por isso lá usamos o
   monograma tipográfico. */
.login-card .brand img {
  width: 84px; height: 84px;
  display: block;
  margin: 0 auto var(--sp-5);
}
.login-card .brand h1 { font-family: var(--brand); font-size: 28px; font-weight: 600; letter-spacing: .01em; }
.login-card .brand p {
  color: var(--text-muted); font-size: 11px; margin: var(--sp-2) 0 0;
  letter-spacing: .18em; text-transform: uppercase; font-weight: 500;
}

/* ----------------------------------------------------------
   4. LAYOUT
   ---------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  padding: var(--sp-6) 0 var(--sp-5);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .logo {
  padding: 0 var(--sp-6) var(--sp-6);
  text-align: center;
}
/* Monograma tipográfico. Substitui o PNG rendilhado da marca, que some
   em tamanho pequeno e traz um dourado amarelo saturado demais para a
   direção "luxo discreto". O arquivo original segue em assets/. */
.sidebar .logo .monograma {
  width: 46px; height: 46px;
  margin: 0 auto var(--sp-4);
  border: 1px solid rgba(179,145,85,.45);
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--brand);
  font-size: 19px; font-weight: 600;
  color: var(--gold-light);
  letter-spacing: .04em;
  padding-left: .04em;
}
.sidebar .logo strong {
  font-family: var(--brand);
  font-size: 21px;
  font-weight: 600;
  color: var(--text-on-dark);
  display: block;
  letter-spacing: .01em;
  line-height: 1.2;
}
.sidebar .logo span {
  font-size: 9.5px;
  color: #8C8880;
  letter-spacing: .26em;
  text-transform: uppercase;
  font-weight: 500;
  display: block;
  margin-top: var(--sp-2);
}
.sidebar .logo::after {
  content: '';
  display: block;
  width: 34px; height: 1px;
  background: rgba(179,145,85,.45);
  margin: var(--sp-5) auto 0;
}

.nav { flex: 1; overflow-y: auto; padding: 0 var(--sp-3); }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); background-clip: content-box; }
.nav a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px var(--sp-3);
  border-radius: var(--radius-md);
  color: #A29E95;
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  transition: background .15s ease, color .15s ease;
}
.nav a svg { width: 18px; height: 18px; color: #B7B3AA; transition: color .15s ease; }
.nav a:hover { background: rgba(255,255,255,.045); color: var(--text-on-dark); }
.nav a:hover svg { color: var(--text-on-dark); }
.nav a.active { background: rgba(179,145,85,.16); color: #E3C88F; font-weight: 600; }
.nav a.active svg { color: #D6B773; }
.nav a.active::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}
.nav .nav-group {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #858079;              /* era #66635D: 3,03:1 sobre a sidebar */
  font-weight: 600;
  padding: var(--sp-5) var(--sp-3) var(--sp-2);
}
.nav .nav-group:first-child { padding-top: var(--sp-1); }

.sidebar-foot { padding: var(--sp-4) var(--sp-5) 0; margin-top: var(--sp-4); }
.sidebar-foot::before {
  content: '';
  display: block;
  height: 1px;
  background: rgba(255,255,255,.07);
  margin-bottom: var(--sp-4);
}
.sidebar-foot .who {
  font-size: 12px; color: #8C8880; margin-bottom: var(--sp-3);
  word-break: break-all; line-height: 1.4;
}

/* ---- Área principal ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-app); }

.topbar {
  display: flex; align-items: center; gap: var(--sp-5);
  padding: var(--sp-5) var(--sp-8);
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-card);
  position: sticky; top: 0; z-index: 30;
}
.topbar h2 {
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.02em;
}
.topbar .sub { color: var(--text-secondary); font-size: 14px; margin-top: 3px; }
.topbar-esq { flex: 1; min-width: 0; }
.topbar-dir { display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0; }
.topbar-acoes { display: flex; align-items: center; gap: var(--sp-2); }
/* Especificidade maior que a do .btn-icon, que também define display */
.topbar .menu-toggle { display: none; }

.content { padding: var(--sp-6) var(--sp-8) var(--sp-12); flex: 1; }

/* ---- Busca global ---- */
.busca-global { position: relative; width: 300px; }
.busca-global input {
  width: 100%;
  height: 40px;
  background: var(--bg-app);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 var(--sp-3) 0 38px;
  color: var(--text-primary);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.busca-global input::placeholder { color: var(--text-muted); }
.busca-global input:focus {
  background: var(--bg-card);
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(179,145,85,.12);
}
.busca-global > svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--text-muted); pointer-events: none;
}
.busca-resultados {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  z-index: 60;
  max-height: 380px; overflow-y: auto;
}
.busca-resultados .grupo {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
  padding: var(--sp-3) var(--sp-4) var(--sp-2);
}
.busca-resultados button {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%; text-align: left;
  padding: 9px var(--sp-4);
  background: none; border: none; cursor: pointer;
  color: var(--text-primary);
  transition: background .12s ease;
}
.busca-resultados button:hover { background: var(--bg-hover); }
.busca-resultados button svg { color: var(--text-muted); width: 16px; height: 16px; }
.busca-resultados .rot { flex: 1; min-width: 0; }
.busca-resultados .rot b { font-weight: 600; display: block; font-size: 13.5px; }
.busca-resultados .rot span { font-size: 12px; color: var(--text-muted); }
.busca-resultados .nada { padding: var(--sp-5) var(--sp-4); color: var(--text-muted); font-size: 13px; text-align: center; }

/* ---- Sino e perfil ---- */
.sino { position: relative; }
.sino .ponto {
  position: absolute; top: 3px; right: 3px;
  min-width: 13px; height: 13px; padding: 0 2px;
  background: var(--danger); color: #fff;
  border-radius: 7px;
  font-size: 9px; font-weight: 700; line-height: 13px; text-align: center;
  border: 1.5px solid var(--bg-card);
  box-sizing: content-box;
  pointer-events: none;
}
.perfil {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 5px var(--sp-3) 5px 5px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
}
.perfil .av {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--black); color: var(--gold-light);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  flex-shrink: 0;
}
.perfil .quem b { display: block; font-size: 13px; font-weight: 600; line-height: 1.3; }
.perfil .quem span { display: block; font-size: 11.5px; color: var(--text-muted); line-height: 1.3; }

/* ----------------------------------------------------------
   5. BOTÕES
   ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -.004em;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--black); color: #fff; }
.btn-primary:hover { background: var(--black-soft); }

.btn-ghost { background: var(--bg-card); border-color: var(--border-default); color: #25241F; }
.btn-ghost:hover { background: var(--bg-hover); border-color: #DED8CD; }

.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); }

.btn-danger { background: var(--bg-card); border-color: var(--danger-line); color: var(--danger-text); }
.btn-danger:hover { background: var(--danger-bg); }

.btn-sm { height: 34px; padding: 0 var(--sp-3); font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-icon svg { width: 17px; height: 17px; display: block; }
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ----------------------------------------------------------
   6. FORMULÁRIOS
   ---------------------------------------------------------- */
.field { margin-bottom: var(--sp-4); }
.field label {
  display: block; margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
}
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 42px;
  background: var(--bg-card);
  border: 1px solid #DEDAD2;
  border-radius: var(--radius-md);
  padding: 10px var(--sp-3);
  color: var(--text-primary);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input::placeholder, .field textarea::placeholder { color: var(--text-muted); }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(179,145,85,.12);
}
.field textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; line-height: 1.45; }

.field-check { display: flex; align-items: center; gap: var(--sp-2); }
.field-check input { width: auto; min-height: 0; accent-color: var(--gold); }
.field-check label,
label.field-check,
label.field-check span {
  margin: 0;
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-primary);
  cursor: pointer;
}

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--sp-5); }
.form-grid .col-full { grid-column: 1 / -1; }
.form-section {
  grid-column: 1 / -1;
  font-size: 11px; letter-spacing: .13em; text-transform: uppercase;
  color: var(--gold-dark); font-weight: 600;
  margin: var(--sp-4) 0 var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-subtle);
}
.form-section:first-child { margin-top: 0; }

/* ----------------------------------------------------------
   7. CARDS E MÉTRICAS
   ---------------------------------------------------------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.card-head h3 { font-size: 17px; font-weight: 600; flex: 1; letter-spacing: -.012em; }
.card-head .ic {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--gold-bg); color: var(--gold-dark);
  display: grid; place-items: center; flex-shrink: 0;
}
.card-head .ic svg { width: 16px; height: 16px; }

/* Métricas do topo */
.kpis {
  /* auto-fit dá a reorganização pedida sem breakpoint fixo: cinco cards
     numa tela larga, 3+2 num notebook, 2+2+1 em tablet, um por linha no
     celular. Telas com quatro métricas se ajustam sozinhas. */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.kpi {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-sm);
  position: relative;
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
button.kpi { cursor: pointer; }
button.kpi:hover { border-color: #DBD4C6; box-shadow: var(--shadow-md); }
.kpi .topo { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.kpi .ic {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--gold-bg); color: var(--gold-dark);
  display: grid; place-items: center; flex-shrink: 0;
}
.kpi .ic svg { width: 17px; height: 17px; }
.kpi .label {
  flex: 1; min-width: 0;
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--text-secondary); font-weight: 600; line-height: 1.35;
}
.kpi .seta { color: var(--text-muted); opacity: 0; transition: opacity .16s ease; }
.kpi .seta svg { width: 16px; height: 16px; }
button.kpi:hover .seta { opacity: 1; }
.kpi .value {
  font-size: 31px; font-weight: 700; line-height: 1.05;
  letter-spacing: -.028em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}
.kpi .value.sm { font-size: 26px; }
.kpi .foot { font-size: 12.5px; color: var(--text-muted); line-height: 1.4; }

.kpi.alerta .ic { background: var(--danger-bg); color: var(--danger-text); }
.kpi.alerta .value { color: var(--danger-text); }
.kpi.positivo .ic { background: var(--success-bg); color: var(--success-text); }

/* compatibilidade com o nome antigo */
.kpi.alert .ic { background: var(--danger-bg); color: var(--danger-text); }
.kpi.alert .value { color: var(--danger-text); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-5); }

/* ----------------------------------------------------------
   8. TABELAS
   ---------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; background: var(--bg-card); }
thead th {
  text-align: left;
  padding: var(--sp-3) var(--sp-5);
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 600;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
  background: var(--bg-card-alt);
}
tbody td { padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--bg-card-alt); }
tbody tr.clickable { cursor: pointer; }
tfoot td { padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border-default); font-weight: 600; }
td .nome { font-weight: 600; letter-spacing: -.006em; }
td .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.acoes { text-align: right; white-space: nowrap; }

/* ----------------------------------------------------------
   9. BADGES
   ---------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 4px var(--sp-2);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -.002em;
  white-space: nowrap;
  background: var(--gold-bg);
  color: var(--gold-dark);
  border: none;
}
.badge.red   { background: var(--danger-bg);  color: var(--danger-text); }
.badge.green { background: var(--success-bg); color: var(--success-text); }
.badge.blue  { background: var(--info-bg);    color: var(--info-text); }
.badge.amber { background: var(--warn-bg);    color: var(--warn-text); }
.badge.mute  { background: var(--bg-subtle);  color: var(--text-secondary); }

/* ----------------------------------------------------------
   10. BARRA DE FILTROS
   ---------------------------------------------------------- */
.toolbar { display: flex; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-5); flex-wrap: wrap; }
.toolbar .search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.toolbar .search input {
  width: 100%; height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 var(--sp-3) 0 38px;
  color: var(--text-primary); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.toolbar .search input::placeholder { color: var(--text-muted); }
.toolbar .search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(179,145,85,.12); }
.toolbar .search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--text-muted); }
.toolbar select {
  height: 40px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 0 var(--sp-3);
  color: var(--text-secondary); outline: none; cursor: pointer;
  font-weight: 500;
  transition: border-color .15s ease;
}
.toolbar select:hover { border-color: #DBD4C6; }
.toolbar select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(179,145,85,.12); }
.toolbar .spacer { flex: 1; }
.toolbar .contador { color: var(--text-muted); font-size: 13px; }

/* ----------------------------------------------------------
   11. KANBAN DO FUNIL
   ---------------------------------------------------------- */
.kanban { display: flex; gap: var(--sp-3); overflow-x: auto; padding-bottom: var(--sp-4); align-items: flex-start; }
.kanban-col {
  /* As colunas dividem a largura disponível para que as seis etapas
     caibam num notebook. Abaixo disso a faixa rola na horizontal. */
  flex: 1 1 0;
  min-width: 182px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex; flex-direction: column;
  max-height: calc(100vh - 250px);
}
.kanban-col.drag-over { border-color: var(--gold); background: var(--gold-bg); }
.kanban-col > header {
  padding: var(--sp-3) var(--sp-4);
  display: flex; align-items: center; gap: var(--sp-2);
}
.kanban-col > header .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); flex-shrink: 0; }
.kanban-col > header h4 {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--text-secondary); font-weight: 700; flex: 1; line-height: 1.3;
}
.kanban-col > header .count {
  font-size: 11px; color: var(--text-secondary); font-weight: 600;
  background: rgba(0,0,0,.05); padding: 2px 7px; border-radius: 5px;
}
.kanban-col .col-total {
  padding: 0 var(--sp-4) var(--sp-3);
  font-size: 12.5px; color: var(--gold-dark); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.kanban-body { padding: 0 var(--sp-2) var(--sp-2); overflow-y: auto; flex: 1; min-height: 60px; }

.deal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  margin-bottom: var(--sp-2);
  cursor: grab;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}
.deal:hover { border-color: #DBD4C6; box-shadow: var(--shadow-md); }
.deal.dragging { opacity: .45; transform: rotate(1.5deg); }
.deal .titulo { font-weight: 600; margin-bottom: 5px; line-height: 1.35; font-size: 13.5px; letter-spacing: -.008em; }
.deal .cliente { font-size: 12px; color: var(--text-muted); margin-bottom: var(--sp-3); display: flex; align-items: center; gap: 5px; }
.deal .cliente svg { width: 13px; height: 13px; }
.deal .rodape { display: flex; align-items: baseline; justify-content: space-between; gap: 4px var(--sp-2); flex-wrap: wrap; }
.deal .valor { font-weight: 700; color: var(--text-primary); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.02em; }
.deal .dias { font-size: 11.5px; color: var(--text-muted); font-weight: 500; }
.deal .dias.frio { color: var(--gold-dark); }
.deal .dias.gelado { color: var(--danger-text); }

/* ----------------------------------------------------------
   12. MODAL
   ---------------------------------------------------------- */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(21,22,21,.42);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--sp-10) var(--sp-5);
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 660px;
  box-shadow: var(--shadow-pop);
  animation: modal-in .18s ease-out;
}
.modal.wide { max-width: 940px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.modal header {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
}
.modal header h3 { font-size: 19px; font-weight: 700; flex: 1; letter-spacing: -.018em; }
.modal .body { padding: var(--sp-6); }
.modal footer {
  display: flex; justify-content: flex-end; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-card-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ----------------------------------------------------------
   13. ABAS
   ---------------------------------------------------------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border-default); margin-bottom: var(--sp-5); overflow-x: auto; }
.tabs button {
  background: none; border: none; cursor: pointer;
  padding: var(--sp-3) var(--sp-4);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color .15s ease, border-color .15s ease;
}
.tabs button:hover { color: var(--text-primary); }
.tabs button.active { color: var(--text-primary); font-weight: 600; border-bottom-color: var(--gold); }

/* ----------------------------------------------------------
   14. LINHA DO TEMPO
   ---------------------------------------------------------- */
.timeline { position: relative; padding-left: var(--sp-6); }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 1px; background: var(--border-default); }
.tl-item { position: relative; padding-bottom: var(--sp-5); }
.tl-item::before {
  content: ''; position: absolute; left: -23px; top: 5px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg-card); border: 2px solid var(--gold);
}
.tl-item.saida::before { border-color: var(--info-text); }
.tl-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: 5px; flex-wrap: wrap; }
.tl-head .quando { font-size: 12px; color: var(--text-muted); }
.tl-item .assunto { font-weight: 600; margin-bottom: 4px; letter-spacing: -.006em; }
.tl-item .conteudo { color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; font-size: 13.5px; }

/* ----------------------------------------------------------
   15. LISTA DE PRAZOS
   ---------------------------------------------------------- */
.prazo {
  display: flex; align-items: flex-start; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
  transition: background .12s ease;
}
.prazo:last-child { border-bottom: none; }
.prazo:hover { background: var(--bg-card-alt); }
.prazo .check {
  width: 19px; height: 19px; flex-shrink: 0; margin-top: 1px;
  border: 1.5px solid #CFC9BC; border-radius: 5px;
  background: var(--bg-card);
  cursor: pointer; display: grid; place-items: center;
  transition: border-color .15s ease, background .15s ease;
}
.prazo .check:hover { border-color: var(--gold); }
.prazo .check svg { width: 12px; height: 12px; opacity: 0; color: var(--gold-dark); }
.prazo .check:hover svg { opacity: .45; }
.prazo .corpo { flex: 1; min-width: 0; }
.prazo .titulo { font-weight: 600; margin-bottom: 6px; font-size: 14.5px; letter-spacing: -.008em; }
.prazo .meta { font-size: 12.5px; color: var(--text-muted); display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.prazo .quando { text-align: right; font-size: 12.5px; white-space: nowrap; }
.prazo .quando strong { display: block; font-size: 13.5px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.prazo .quando span { color: var(--text-muted); }
.prazo.atrasada .quando strong { color: var(--danger-text); }
.prazo.hoje .quando strong { color: var(--gold-dark); }
.prazo.feita { opacity: .5; }
.prazo.feita .titulo { text-decoration: line-through; }
.prazo.feita .check { background: var(--gold-bg); border-color: var(--gold); }
.prazo.feita .check svg { opacity: 1; }

/* Linha genérica de lista dentro de card */
.linha {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border-subtle);
}
.linha:last-child { border-bottom: none; }
.linha .corpo { flex: 1; min-width: 0; }
.linha .tit { font-weight: 600; font-size: 14px; letter-spacing: -.008em; }
.linha .sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.linha .dir { text-align: right; white-space: nowrap; }
.linha .dir .val { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.linha .dir .qdo { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* Avatar de iniciais */
.av-ini {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--bg-subtle); color: var(--text-secondary);
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700; letter-spacing: .02em;
  flex-shrink: 0;
}

/* ----------------------------------------------------------
   16. GRÁFICOS
   ---------------------------------------------------------- */
.bar-row { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.bar-row .rot { width: 150px; flex-shrink: 0; font-size: 13px; color: var(--text-secondary); }
.bar-row .trilho { flex: 1; height: 22px; background: var(--bg-subtle); border-radius: var(--radius-sm); overflow: hidden; }
.bar-row .barra { height: 100%; background: var(--gold); border-radius: var(--radius-sm); min-width: 2px; }
.bar-row .val { width: 76px; text-align: right; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; flex-shrink: 0; }

.funnel-step { display: flex; align-items: center; gap: var(--sp-4); margin-bottom: var(--sp-2); }
.funnel-step .etapa { width: 158px; flex-shrink: 0; font-size: 13px; color: var(--text-secondary); }
.funnel-step .bloco {
  background: var(--gold-bg);
  border-radius: var(--radius-md); padding: 10px var(--sp-4);
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
}
.funnel-step .bloco b { color: var(--gold-dark); font-size: 16px; font-weight: 700; }
.funnel-step .taxa { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

/* ----------------------------------------------------------
   17. ESTADOS
   ---------------------------------------------------------- */
.empty { text-align: center; padding: var(--sp-12) var(--sp-5); color: var(--text-muted); }
.empty svg { width: 30px; height: 30px; margin-bottom: var(--sp-3); opacity: .5; }
.empty p { margin: 0 0 var(--sp-4); font-size: 13.5px; }
.loading { text-align: center; padding: var(--sp-12); color: var(--text-muted); }
.spinner {
  width: 24px; height: 24px; margin: 0 auto var(--sp-3);
  border: 2px solid var(--border-default); border-top-color: var(--gold);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.erro-box {
  background: #FFF0EF;
  border: 1px solid var(--danger-line);
  color: #A84540;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-4);
  font-size: 13.5px;
  line-height: 1.5;
  display: flex; align-items: flex-start; gap: var(--sp-3);
}
.erro-box svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }

/* ----------------------------------------------------------
   18. TOASTS
   ---------------------------------------------------------- */
.toasts { position: fixed; bottom: var(--sp-6); right: var(--sp-6); z-index: 300; display: flex; flex-direction: column; gap: var(--sp-2); }
/* O estado vem do ícone, não de uma barra colorida na lateral. Cor
   sozinha não serve como único indicador de sucesso ou erro. */
.toast {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  min-width: 250px; max-width: 380px;
  font-size: 13.5px; font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: toast-in .2s ease-out;
}
.toast svg { width: 17px; height: 17px; margin-top: 1px; color: var(--text-muted); }
.toast.ok svg { color: var(--success-text); }
.toast.erro svg { color: var(--danger-text); }
.toast.erro { border-color: var(--danger-line); }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ----------------------------------------------------------
   19. FICHA DE DETALHE
   ---------------------------------------------------------- */
.detalhe-head { display: flex; align-items: flex-start; gap: var(--sp-5); margin-bottom: var(--sp-6); flex-wrap: wrap; }
.detalhe-head .avatar {
  width: 54px; height: 54px; border-radius: var(--radius-lg); flex-shrink: 0;
  background: var(--black); color: var(--gold-light);
  display: grid; place-items: center;
  font-size: 17px; font-weight: 600;
}
.detalhe-head .info { flex: 1; min-width: 200px; }
.detalhe-head .info h2 { font-size: 23px; font-weight: 700; margin-bottom: 6px; letter-spacing: -.02em; }
.detalhe-head .info .linha {
  color: var(--text-secondary); font-size: 13.5px;
  display: flex; gap: var(--sp-4); flex-wrap: wrap;
  padding: 0; border: none;
}

.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-5); }
.dl .item .rot { font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: 5px; }
.dl .item .val { color: var(--text-primary); word-break: break-word; font-weight: 500; }
.dl .item .val.vazio { color: var(--text-muted); font-weight: 400; }
.dl .item .val.destaque { font-size: 21px; font-weight: 700; letter-spacing: -.02em; }

/* Rótulo solto reaproveitado nas fichas */
.rot-mini { font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase; color: var(--text-muted); font-weight: 600; margin-bottom: 6px; }
.texto-longo { color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; }

/* ----------------------------------------------------------
   20. RESPONSIVO
   Prioridade: desktop de 1366px a 1920px.
   ---------------------------------------------------------- */
@media (max-width: 1500px) {
  .busca-global { width: 240px; }
}
@media (max-width: 1180px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .busca-global { width: 200px; }
  .perfil .quem { display: none; }
  .perfil { padding: 5px; }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 90;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 48px rgba(0,0,0,.28);
  }
  .sidebar.aberta { transform: none; }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar { padding: var(--sp-4) var(--sp-5); gap: var(--sp-3); }
  .topbar h2 { font-size: 22px; }
  .topbar .sub { font-size: 13px; }
  .busca-global { display: none; }
  .content { padding: var(--sp-5) var(--sp-5) var(--sp-12); }
  .form-grid { grid-template-columns: 1fr; }
  .modal-bg { padding: var(--sp-4) var(--sp-3); }
  .bar-row .rot { width: 104px; font-size: 12.5px; }
  .funnel-step .etapa { width: 108px; font-size: 12.5px; }
  .detalhe-head .info h2 { font-size: 20px; }
  .prazo { padding: var(--sp-4) var(--sp-5); }
}
