/* ═══════════════════════════════════════════
   VARIÁVEIS — DESIGN SYSTEM CAMARGO
═══════════════════════════════════════════ */
:root {
  /* Paleta vinho / dourado */
  --wine-darkest: #120306;
  --wine-dark:    #3d0e16;
  --wine:         #6b1a28;
  --wine-mid:     #8b2535;
  --wine-light:   #c4788a;
  --wine-pale:    #f8f0f2;
  --gold:         #b8955a;
  --gold-light:   #d4b07a;
  --ink:          #18080e;
  --muted:        #7a6670;
  --border:       #e6dadd;
  --bg:           #fdfbfc;
  --bg2:          #f5eff1;
  --green:        #2a6e47;
  --green-bg:     #eaf5f0;
  --red:          #b03030;
  --red-bg:       #fceaea;

  /* Aliases de compatibilidade (usados em estilos inline do app.js) */
  --navy:       #6b1a28;
  --navy-dark:  #3d0e16;
  --navy-light: #8b2535;
  --white:      #ffffff;
  --text:       #18080e;
  --text-mid:   #7a6670;
  --text-soft:  #6a5862;
  --success:    #2a6e47;
  --warning:    #b87e1a;
  --danger:     #b03030;
  --info:       #6b1a28;

  /* Fichas */
  --radius:    8px;
  --radius-lg: 12px;
  --shadow:    0 1px 4px rgba(18,3,6,.06), 0 1px 2px rgba(18,3,6,.04);
  --shadow-md: 0 4px 16px rgba(61,14,22,.12);
  --sidebar-w: 220px;
}

/* ─── Reset ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ─── Tipografia de destaque ─── */
h1, h2, h3,
.page-title, .card-title, .modal-title,
.kpi-value, .section-title-serif,
.topbar-title {
  font-family: 'Libre Baskerville', Georgia, serif;
}

/* ─── Skip link ─── */
.skip-link {
  position: absolute; top: -200px; left: 12px; z-index: 9999;
  background: var(--wine-dark); color: #fff;
  padding: 10px 20px; border-radius: 0 0 8px 8px;
  font-size: 14px; font-weight: 700; text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; outline: 2px solid var(--gold); outline-offset: 2px; }

/* ─── Screen-reader only ─── */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ═══════════════════════════════════════════
   SPLASH
═══════════════════════════════════════════ */
.splash {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; gap: 18px; background: var(--wine-dark); color: var(--white);
}
.splash-logo {
  width: 76px; height: 76px; border-radius: 50%;
  background: linear-gradient(135deg, var(--wine), var(--wine-mid));
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Libre Baskerville', serif;
  font-size: 26px; font-weight: 700; color: var(--gold);
}
.splash p { color: rgba(255,255,255,.45); font-size: 13px; }

/* ═══════════════════════════════════════════
   LOGIN — Layout split
═══════════════════════════════════════════ */
.login-wrap {
  min-height: 100vh; display: flex;
}

/* Painel esquerdo — vinho escuro */
.login-panel-left {
  width: 420px; flex-shrink: 0;
  background: var(--wine-dark);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px 40px;
  position: relative; overflow: hidden;
}
.login-panel-left::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 29px, rgba(255,255,255,.03) 30px);
  pointer-events: none;
}
.login-panel-left::after {
  content: '';
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 1px;
  background: linear-gradient(180deg, transparent, var(--gold), transparent);
}
.login-brand { position: relative; z-index: 1; text-align: center; }
.login-monogram {
  width: 88px; height: 88px; border-radius: 50%;
  background: linear-gradient(135deg, var(--wine), var(--wine-mid));
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Libre Baskerville', serif;
  font-size: 32px; font-weight: 700; color: var(--gold);
  margin: 0 auto 24px;
}
.login-firm-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 22px; font-weight: 700; color: var(--white);
  line-height: 1.3; margin-bottom: 8px;
}
.login-firm-sub {
  font-size: 12px; color: rgba(255,255,255,.45); letter-spacing: .04em;
}
.login-gold-rule {
  width: 48px; height: 1px; margin: 20px auto;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* Painel direito — formulário */
.login-panel-right {
  flex: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg); padding: 48px 32px;
}
.login-form-wrap {
  width: 100%; max-width: 340px;
}
.login-form-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 20px; font-weight: 700; color: var(--ink);
  margin-bottom: 6px;
}
.login-form-sub {
  font-size: 13px; color: var(--muted); margin-bottom: 28px;
}
.login-links {
  display: flex; justify-content: space-between; margin-top: 16px;
}
.login-link {
  background: none; border: none; color: var(--muted);
  font-size: 12px; cursor: pointer; text-decoration: underline;
  font-family: inherit;
}
.login-link:hover { color: var(--wine); }

/* Compat: renderLogin usa .login-card internamente — mapeamos para form-wrap */
.login-card {
  width: 100%; max-width: 340px;
  background: none; border-radius: 0; padding: 0; box-shadow: none;
}
.login-logo { display: none; }   /* oculto no novo layout split */

/* ─── Tela de redefinição / cadastro (usa .login-card) ─── */
.login-wrap.login-centered {
  align-items: center; justify-content: center;
  background: var(--wine-dark);
}
.login-wrap.login-centered .login-card {
  background: var(--white); border-radius: var(--radius-lg);
  padding: 40px 36px; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-wrap.login-centered .login-logo { display: block; text-align: center; margin-bottom: 28px; }
.login-wrap.login-centered .login-logo .logo-mark {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--wine), var(--wine-mid));
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Libre Baskerville', serif;
  font-size: 20px; font-weight: 700; color: var(--gold);
  margin: 0 auto 12px;
}
.login-wrap.login-centered .login-logo h1 {
  font-family: 'Libre Baskerville', serif;
  font-size: 18px; font-weight: 700; color: var(--ink);
}
.login-wrap.login-centered .login-logo p { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ═══════════════════════════════════════════
   LAYOUT PRINCIPAL
═══════════════════════════════════════════ */
.app-layout { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--wine-dark);
  color: var(--white);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100;
  transition: transform .25s ease;
  background-color: var(--wine-dark);
  /* Filete dourado na borda direita */
  border-right: 1px solid transparent;
  box-shadow: inset -1px 0 0 rgba(184,149,90,.35);
}

.sidebar-header {
  padding: 22px 18px 18px;
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--wine), var(--wine-mid));
  border: 1.5px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Libre Baskerville', serif;
  font-size: 13px; font-weight: 700; color: var(--gold);
  flex-shrink: 0;
}
.sidebar-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 12px; font-weight: 700; color: var(--white);
  line-height: 1.3;
}
.sidebar-title span { display: block; font-family: 'DM Sans', sans-serif; font-weight: 400; font-size: 10px; color: rgba(255,255,255,.4); margin-top: 1px; }

.sidebar-search {
  padding: 0 14px 14px;
}
.sidebar-search input {
  width: 100%; background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 6px; padding: 8px 12px;
  color: var(--white); font-size: 12px; outline: none;
  transition: background .15s;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,.3); }
.sidebar-search input:focus { background: rgba(255,255,255,.12); border-color: var(--gold); }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }
.nav-section-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 9px; font-weight: 600; color: rgba(255,255,255,.28);
  text-transform: uppercase; letter-spacing: .1em; padding: 14px 18px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px; font-size: 13px; font-weight: 500;
  width: 100%; background: none; border: none; text-align: left;
  color: rgba(255,255,255,.65); cursor: pointer;
  transition: background .12s, color .12s;
  border-left: 2px solid transparent;
  border-bottom: 1px solid rgba(255,255,255,.04);
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--white); }
.nav-item.active {
  background: rgba(255,255,255,.07);
  color: var(--gold-light);
  border-left-color: var(--gold);
}
.nav-item .nav-icon { font-size: 15px; width: 20px; text-align: center; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 12px; color: rgba(255,255,255,.35);
}
/* Avatar do usuário */
.sidebar-user-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--wine), var(--wine-mid));
  border: 1.5px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Libre Baskerville', serif;
  font-size: 12px; font-weight: 700; color: var(--gold);
}
.sidebar-user { font-weight: 600; color: rgba(255,255,255,.85); font-size: 13px; }
.sidebar-role { font-size: 10px; color: rgba(255,255,255,.35); }
.btn-logout {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: rgba(255,255,255,.5);
  padding: 7px 14px; border-radius: 6px; font-size: 12px; width: 100%;
  transition: background .15s, color .15s; min-height: 40px;
}
.btn-logout:hover { background: rgba(176,48,48,.3); color: #fca5a5; border-color: rgba(176,48,48,.4); }

/* ─── MAIN CONTENT ─── */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
  display: flex; flex-direction: column;
}

/* ─── TOPBAR ─── */
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 18px 32px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 20px; font-weight: 700; color: var(--ink); flex: 1;
}
.topbar-back { display: flex; align-items: center; gap: 6px; }
.btn-nav {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 14px; font-size: 12px; font-weight: 500; color: var(--muted);
  cursor: pointer; transition: all .15s; min-height: 36px; white-space: nowrap;
  font-family: inherit;
}
.btn-nav:hover { background: var(--wine-pale); color: var(--wine); border-color: var(--wine-light); }
.btn-nav-home { padding: 6px 12px; font-size: 14px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; width: 300px;
}
.topbar-search input { border: none; background: none; outline: none; font-size: 13px; flex: 1; color: var(--ink); }
.topbar-search input::placeholder { color: var(--muted); }
.topbar-search .search-icon { color: var(--muted); font-size: 15px; }

.page-body { padding: 32px; flex: 1; background: var(--bg2); }

/* ═══════════════════════════════════════════
   CARDS
═══════════════════════════════════════════ */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  /* Faixa de categoria no topo — padrão vinho */
  border-top: 2px solid var(--wine);
}
.card.card-green  { border-top-color: var(--green); }
.card.card-red    { border-top-color: var(--red); }
.card.card-gold   { border-top-color: var(--gold); }
.card.card-plain  { border-top-color: var(--border); }

.card-header {
  padding: 20px 24px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
/* Separador interno dourado */
.card-header + .card-body,
.card-header + div {
  position: relative;
}
.gold-rule {
  display: block; height: 1px; margin: 0 24px;
  background: linear-gradient(90deg, transparent, var(--gold) 30%, var(--gold) 70%, transparent);
  opacity: .25;
}
.card-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 14px; font-weight: 700; color: var(--ink);
}
.card-body { padding: 22px 24px; }

/* KPI Cards */
.kpi-grid   { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 28px; }
@media (max-width: 960px) {
  .kpi-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .kpi-grid-4, .kpi-grid-3 { grid-template-columns: 1fr; }
}
.kpi-card {
  background: var(--white); border-radius: var(--radius-lg);
  border: 1px solid var(--border); border-top: 2px solid var(--wine);
  padding: 22px 24px; box-shadow: var(--shadow);
}
.kpi-card.card-green  { border-top-color: var(--green); }
.kpi-card.card-red    { border-top-color: var(--red); }
.kpi-card.card-gold   { border-top-color: var(--gold); }
.kpi-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 11px; color: var(--muted); font-weight: 500;
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 10px;
}
.kpi-value {
  font-family: 'Libre Baskerville', serif;
  font-size: 34px; font-weight: 700; color: var(--ink);
  line-height: 1;
}
.kpi-sub   { font-size: 11px; color: var(--muted); margin-top: 6px; }
.kpi-card.danger .kpi-value  { color: var(--red); }
.kpi-card.success .kpi-value { color: var(--green); }
.kpi-card.warning .kpi-value { color: var(--warning); }
.kpi-clickable { cursor: pointer; transition: transform .1s, box-shadow .1s; }
.kpi-clickable:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--wine-light); }
.kpi-clickable:focus-visible { outline: 2px solid var(--wine); outline-offset: 2px; border-radius: var(--radius-lg); }

/* Grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: stretch; }
.grid-2 > .card { height: 100%; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px; }

/* ═══════════════════════════════════════════
   BOTÕES
═══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 20px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  border: none; transition: all .15s; white-space: nowrap;
  min-height: 40px; font-family: inherit;
}
.btn-primary   { background: var(--wine); color: var(--white); }
.btn-primary:hover { background: var(--wine-mid); }
.btn-gold      { background: var(--gold); color: var(--wine-darkest); }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline   { background: transparent; color: var(--wine); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--wine-pale); border-color: var(--wine-light); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { background: #8f2626; }
.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover { background: #1f5234; }
.btn-ghost     { background: transparent; color: var(--muted); border: none; padding: 6px 10px; }
.btn-ghost:hover { background: var(--wine-pale); color: var(--wine); }
.btn-sm        { padding: 5px 14px; font-size: 12px; min-height: 36px; }
.btn-icon      { padding: 8px; border-radius: 6px; min-width: 36px; min-height: 36px; justify-content: center; }
.btn:disabled  { opacity: .45; cursor: not-allowed; }

/* ═══════════════════════════════════════════
   FORMULÁRIOS
═══════════════════════════════════════════ */
.form-group  { margin-bottom: 18px; }
.form-label  {
  display: block;
  font-family: 'Libre Baskerville', serif;
  font-size: 12px; font-weight: 700; color: var(--ink);
  margin-bottom: 6px;
}
.form-label span.req { color: var(--red); }
.form-control {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; color: var(--ink); background: var(--bg2);
  outline: none; transition: border .15s, box-shadow .15s;
  font-family: inherit;
}
.form-control:focus {
  border-color: var(--wine-light);
  box-shadow: 0 0 0 3px rgba(196,120,138,.08);
  background: var(--white);
}
.form-control[readonly] { background: var(--bg); color: var(--muted); }
textarea.form-control { resize: vertical; min-height: 88px; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ═══════════════════════════════════════════
   TABELAS
═══════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  font-family: 'DM Sans', sans-serif;
  text-align: left; font-size: 11px; font-style: normal; font-weight: 600;
  color: var(--text-soft); letter-spacing: .04em; text-transform: uppercase;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--bg2); white-space: nowrap;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--wine-pale); }

/* Ações de linha visíveis só no hover */
.row-actions { opacity: 0; transition: opacity .15s; display: flex; gap: 6px; }
tbody tr:hover .row-actions { opacity: 1; }

.table-empty { text-align: center; padding: 48px; color: var(--muted); }

/* Filtros */
.filters-bar { display: flex; gap: 10px; margin-bottom: 24px; flex-wrap: wrap; align-items: center;
  padding: 14px 16px; background: var(--bg2); border-radius: var(--radius); border: 1px solid var(--border);
}
.filter-select {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 12px; background: var(--white); color: var(--ink); outline: none;
  font-family: inherit;
}
.filter-select:focus { border-color: var(--wine-light); }

/* ═══════════════════════════════════════════
   BADGES
═══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; padding: 4px 12px;
  border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
/* Status cliente */
.badge-em_atendimento   { background: var(--bg2); color: var(--muted); }
.badge-proposta_enviada { background: #fef3e2; color: #8a5a00; }
.badge-contratado       { background: var(--green-bg); color: var(--green); }
.badge-ativo            { background: var(--green-bg); color: var(--green); }
.badge-encerrado        { background: var(--bg2); color: var(--muted); }
.badge-arquivado        { background: var(--bg2); color: #bbaab0; }
/* Status processo */
.badge-ativo-case   { background: var(--green-bg); color: var(--green); }
.badge-aguardando   { background: #fef3e2; color: #8a5a00; }
/* Status financeiro */
.badge-pendente  { background: #fef3e2; color: #8a5a00; }
.badge-parcial   { background: #eef1fe; color: #3540b0; }
.badge-quitado   { background: var(--green-bg); color: var(--green); }
.badge-cancelado { background: var(--red-bg); color: var(--red); }

/* Badges de parcela */
.inst-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.inst-badge-paid    { background: var(--green-bg); color: var(--green); }
.inst-badge-overdue { background: var(--red-bg);   color: var(--red); }
.inst-badge-pending { background: #fef3e2;          color: #8a5a00; }

/* Badge DataJud */
.badge-datajud { background: #eeeaf8; color: #5b21b6; font-size: 10px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }

/* ═══════════════════════════════════════════
   ABAS
═══════════════════════════════════════════ */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 28px; gap: 2px; }
.tab {
  padding: 10px 22px; font-size: 13px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; cursor: pointer; transition: all .15s;
  font-family: 'DM Sans', sans-serif;
}
.tab:hover  { color: var(--wine); }
.tab.active {
  color: var(--wine);
  border-bottom-color: var(--wine);
  font-weight: 600;
}

/* ═══════════════════════════════════════════
   TIMELINE
═══════════════════════════════════════════ */
.timeline { padding: 4px 0; }
.timeline-item {
  display: flex; gap: 16px; padding: 0 0 26px 0; position: relative;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ''; position: absolute; left: 17px; top: 34px; bottom: 0;
  width: 1px; background: var(--border);
}
.timeline-item:last-child::before { display: none; }
.timeline-icon {
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0; position: relative; z-index: 1;
  border: 1px solid var(--border);
}
.tl-reuniao             { background: #eef1fe; }
.tl-email               { background: var(--green-bg); }
.tl-ligacao             { background: #fef3e2; }
.tl-whatsapp            { background: var(--green-bg); }
.tl-mensagem            { background: var(--bg2); }
.tl-movimentacao_processual { background: var(--wine-pale); }
.tl-documento           { background: #fef9e2; }
.tl-proposta            { background: #fef3e2; }
.tl-contrato            { background: var(--green-bg); }
.tl-outro               { background: var(--bg2); }
.timeline-content { flex: 1; min-width: 0; }
.timeline-header { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.timeline-title  { font-size: 13px; font-weight: 600; color: var(--ink); }
.timeline-date   { font-size: 11px; color: var(--muted); }
.timeline-case   { font-size: 11px; color: var(--wine); }
.timeline-desc   { font-size: 12px; color: var(--muted); white-space: pre-line; }
.timeline-by     { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ═══════════════════════════════════════════
   PARTES DO PROCESSO
═══════════════════════════════════════════ */
.parties-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.party-tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 12px;
  border-radius: 20px; font-size: 11px; border: 1px solid var(--border); background: var(--bg2);
  color: var(--muted);
}
.party-role-autor        { border-color: #b8c9f0; background: #eef1fe; color: #1d4ed8; }
.party-role-reu          { border-color: #f0b8b8; background: var(--red-bg); color: var(--red); }
.party-role-terceiro_interessado { border-color: #c4b5fd; background: #f5f3ff; color: #6d28d9; }
.party-role-assistente   { border-color: #a8d8bc; background: var(--green-bg); color: var(--green); }
.party-role-litisconsorte{ border-color: #e2c97a; background: #fef8e2; color: #7a5800; }
.party-role-outro        { border-color: var(--border); }

/* Destaque "Nosso Cliente" */
.party-tag-ours {
  border-color: var(--gold) !important;
  background: linear-gradient(135deg, #fef9e7, #fdf3d1) !important;
  box-shadow: 0 0 0 1px rgba(184,149,90,.25);
  font-weight: 700;
}
.party-our-client td {
  background: #fefbf0 !important;
}
.party-our-client td:first-child {
  border-left: 3px solid var(--gold);
}
.our-client-star { font-size: 12px; margin-right: 2px; }
.party-client-check {
  flex: 0 0 auto; white-space: nowrap; font-size: 11px;
  padding: 4px 8px; border-radius: 6px; background: var(--bg2);
  border: 1px solid var(--border); gap: 4px !important;
}
.party-client-check:has(input:checked) {
  background: #fef9e7; border-color: var(--gold); color: var(--gold-dark, #7a5800);
}

/* ═══════════════════════════════════════════
   PARCELAS
═══════════════════════════════════════════ */
.installment-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.installment-item:last-child { border-bottom: none; }
.inst-info   { flex: 1; }
.inst-amount { font-weight: 600; font-size: 13px; color: var(--ink); }
.inst-date   { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ═══════════════════════════════════════════
   MODAL
═══════════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(18,3,6,.55);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--white); border-radius: var(--radius-lg);
  border-top: 2px solid var(--wine);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(18,3,6,.3);
}
.modal-lg { max-width: 720px; }
.modal-header {
  padding: 20px 24px 16px; display: flex; align-items: center; justify-content: space-between;
}
.modal-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 15px; font-weight: 700; color: var(--ink);
}
.modal-close {
  width: 32px; height: 32px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg2); color: var(--muted); font-size: 18px;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.modal-close:hover { background: var(--wine-pale); color: var(--wine); border-color: var(--wine-light); }
.modal-body   { padding: 4px 24px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
#toast-container { position: fixed; top: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 280px; max-width: 360px; padding: 14px 18px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-md);
  animation: toastIn .25s ease; display: flex; align-items: center; gap: 10px;
}
.toast-success { background: var(--green-bg); border: 1px solid #a8d8bc; color: var(--green); }
.toast-error   { background: var(--red-bg);   border: 1px solid #f0b8b8; color: var(--red); }
.toast-info    { background: var(--wine-pale); border: 1px solid var(--wine-light); color: var(--wine); }
@keyframes toastIn { from { opacity:0; transform:translateX(20px) } to { opacity:1; transform:none } }

/* ═══════════════════════════════════════════
   HERO DO CLIENTE
═══════════════════════════════════════════ */
.client-hero {
  background: var(--wine-dark);
  background-image: repeating-linear-gradient(0deg, transparent, transparent 23px, rgba(255,255,255,.025) 24px);
  border-radius: var(--radius-lg); padding: 32px 36px;
  color: var(--white); margin-bottom: 28px; position: relative; overflow: hidden;
  border-bottom: 2px solid var(--gold);
}
.client-hero::after {
  content: 'CA'; position: absolute; right: 28px; top: 50%; transform: translateY(-50%);
  font-family: 'Libre Baskerville', serif;
  font-size: 90px; font-weight: 700; color: rgba(184,149,90,.10); pointer-events: none;
}
.client-hero-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 24px; font-weight: 700; margin-bottom: 8px;
}
.client-hero-meta { display: flex; gap: 22px; flex-wrap: wrap; font-size: 12px; color: rgba(255,255,255,.55); }
.client-hero-meta span { display: flex; align-items: center; gap: 5px; }
.client-hero-actions { display: flex; gap: 8px; margin-top: 22px; }

/* ═══════════════════════════════════════════
   PROCESSO — CARDS E DETALHE
═══════════════════════════════════════════ */
.case-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  border-top: 2px solid var(--wine);
  padding: 18px 22px; margin-bottom: 14px;
  background: var(--white); transition: all .15s;
}
.case-card:hover { border-color: var(--wine-light); box-shadow: var(--shadow-md); }
.case-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.case-card-clickable {
  flex: 1; min-width: 0; cursor: pointer; border-radius: 4px; padding: 2px 4px; margin: -2px -4px;
}
.case-card-clickable:hover .case-card-title { color: var(--wine); text-decoration: underline; }
.case-card-clickable:focus { outline: 2px solid var(--wine-light); outline-offset: 2px; }
.case-card-title  {
  font-family: 'Libre Baskerville', serif;
  font-size: 14px; font-weight: 700; color: var(--ink); transition: color .1s;
}
.case-card-meta   { font-size: 12px; color: var(--muted); margin-top: 5px; }
.case-card-footer { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; align-items: center; }
.court-link { color: var(--wine); font-size: 11px; text-decoration: underline; }
.datajud-sync { font-size: 11px; color: var(--muted); }

/* Detalhe de processo */
.case-detail-wrap { max-width: 960px; margin: 0 auto; }
.case-detail-grid { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 768px) { .case-detail-grid { grid-template-columns: 1fr; } }
.detail-row {
  display: flex; align-items: baseline; gap: 14px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.detail-row:last-of-type { border-bottom: none; }
.detail-label {
  font-family: 'Libre Baskerville', serif;
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px;
  flex-shrink: 0; min-width: 130px;
}
.text-link {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--wine); font-size: inherit; text-decoration: underline;
  font-family: inherit;
}
.text-link:hover { color: var(--wine-mid); }

/* Clientes vinculados */
.linked-clients-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border);
}
.linked-client-tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 12px; border-radius: 20px; font-size: 11px; font-weight: 500;
  background: var(--wine-pale); color: var(--wine); border: 1px solid var(--wine-light);
  cursor: pointer; transition: all .15s;
}
.linked-client-tag:hover { background: #f0d8de; }
.linked-remove {
  margin-left: 2px; color: var(--wine-light); font-size: 14px; line-height: 1;
  cursor: pointer; font-weight: 700;
}
.linked-remove:hover { color: var(--red); }

/* ═══════════════════════════════════════════
   EMPTY STATE
═══════════════════════════════════════════ */
.empty-state { text-align: center; padding: 64px 20px; color: var(--muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 18px; opacity: .35; }
.empty-state h3 {
  font-family: 'Libre Baskerville', serif;
  font-size: 16px; color: var(--ink); margin-bottom: 8px;
}
.empty-state p { font-size: 13px; }

/* ═══════════════════════════════════════════
   CHECKBOX / PARTROW
═══════════════════════════════════════════ */
.check-group { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check-group input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--wine); cursor: pointer; }
.party-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.party-row .form-control { margin-bottom: 0; }

/* Toggle de modo de vencimento de parcelas */
.inst-mode-toggle {
  display: inline-flex; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: var(--bg2);
}
.inst-mode-btn {
  padding: 7px 16px; font-size: 12px; font-weight: 500;
  border: none; background: transparent; color: var(--muted);
  cursor: pointer; transition: all .15s; font-family: inherit;
  white-space: nowrap;
}
.inst-mode-btn:not(:last-child) { border-right: 1px solid var(--border); }
.inst-mode-btn:hover { background: var(--wine-pale); color: var(--wine); }
.inst-mode-btn.active {
  background: var(--wine); color: var(--white); font-weight: 600;
}

/* ═══════════════════════════════════════════
   FOCO / ACESSIBILIDADE
═══════════════════════════════════════════ */
*:focus-visible {
  outline: 2px solid var(--wine-light);
  outline-offset: 2px;
  border-radius: 3px;
}
button:focus-visible { outline-color: var(--gold); }
/* Elementos de layout estrutural não devem exibir outline de foco */
main:focus, main:focus-visible,
.main-content:focus, .main-content:focus-visible,
.page-body:focus, .page-body:focus-visible,
.app-layout:focus, .app-layout:focus-visible {
  outline: none;
}

/* ═══════════════════════════════════════════
   HAMBÚRGUER / OVERLAY MOBILE
═══════════════════════════════════════════ */
.hamburger {
  display: none; background: none; border: none;
  font-size: 22px; cursor: pointer; padding: 6px 8px;
  color: var(--muted); border-radius: 6px; line-height: 1;
  min-height: 44px; min-width: 44px; justify-content: center;
}
.hamburger:hover { background: var(--wine-pale); color: var(--wine); }
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(18,3,6,.5); z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ═══════════════════════════════════════════
   RESPONSIVO
═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .hamburger { display: flex; align-items: center; }
  .sidebar { transform: translateX(-100%); box-shadow: none; transition: transform .25s ease, box-shadow .25s ease; }
  .sidebar.open { transform: none; box-shadow: 4px 0 24px rgba(18,3,6,.4); }
  .main-content { margin-left: 0; }
  .page-body { padding: 16px; }
  .topbar { padding: 14px 16px; gap: 10px; }
  .topbar-search { display: none; }
  .topbar-title { font-size: 16px; }
  .form-row, .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .client-hero { padding: 22px 20px; }
  .client-hero::after { display: none; }
  .modal { margin: 0 8px; max-height: 95vh; }
  /* Login mobile: empilha */
  .login-wrap { flex-direction: column; }
  .login-panel-left { width: 100%; padding: 36px 24px 28px; min-height: auto; }
  .login-panel-right { padding: 32px 24px; }
}

/* ═══════════════════════════════════════════
   UTILITÁRIOS
═══════════════════════════════════════════ */
.text-soft    { color: var(--muted); }
.text-mid     { color: var(--muted); }
.text-navy    { color: var(--wine); }
.text-gold    { color: var(--gold); }
.text-success { color: var(--green); }
.text-danger  { color: var(--red); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12  { font-size: 12px; }
.fs-13  { font-size: 13px; }
.mt-4   { margin-top: 4px; }
.mt-8   { margin-top: 8px; }
.mt-12  { margin-top: 12px; }
.mt-16  { margin-top: 16px; }
.mt-24  { margin-top: 24px; }
.mb-4   { margin-bottom: 4px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.section-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 16px;
}

/* ═══════════════════════════════════════════
   ABA FINANÇAS — COMPONENTES EXCLUSIVOS
═══════════════════════════════════════════ */

/* ─── Cabeçalho da página ─── */
.fin-overview { max-width: 1200px; }
.fin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

/* ─── Borda vermelha lateral em cards de alerta ─── */
.card-danger-border { border-left: 4px solid var(--red); }

/* ─── Gráfico de barras de recebimentos ─── */
.fin-bar-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  gap: 8px;
  height: 160px;
  padding: 0 8px;
}
.fin-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 4px 4px 0;
  transition: background .15s;
}
.fin-bar-col:hover { background: var(--wine-pale); }

.fin-bar-val {
  font-size: 10px;
  font-weight: 700;
  color: var(--wine);
  text-align: center;
  min-height: 18px;
  word-break: break-all;
  line-height: 1.2;
}
.fin-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 4px 8px 4px;
}
.fin-bar {
  width: 100%;
  max-width: 48px;
  background: var(--wine-light);
  border-radius: 4px 4px 0 0;
  transition: height .35s ease, background .2s;
  min-height: 4px;
}
.fin-bar.fin-bar-active {
  background: var(--wine);
  box-shadow: 0 0 0 2px var(--gold);
}
.fin-bar-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 2px;
  white-space: nowrap;
}
.fin-bar-label-active {
  color: var(--wine);
  font-weight: 700;
}

/* ─── Lista de parcelas vencidas ─── */
.overdue-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.overdue-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.overdue-item:last-child { border-bottom: none; }

.overdue-item-info {
  flex: 1;
  min-width: 0;
}
.overdue-item-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.overdue-item-meta {
  font-size: 12px;
  color: var(--muted);
}
.overdue-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  white-space: nowrap;
}
.overdue-item-amount {
  font-weight: 700;
  font-size: 15px;
  color: var(--red);
}

/* ─── Botão-link (inline nav) ─── */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--wine);
  font-weight: 600;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--wine-mid); }

/* ─── Responsividade ─── */
@media (max-width: 640px) {
  .fin-bar-chart { height: 110px; }
  .fin-bar-val   { font-size: 9px; }
  .fin-bar-label { font-size: 10px; }
  .overdue-item  { flex-wrap: wrap; }
  .overdue-item-right { flex-direction: row; align-items: center; }
  .fin-header    { flex-direction: column; }
}

/* ─── Autocomplete ─── */
.autocomplete-container { position: relative; }
.autocomplete-results {
  position: absolute; top: 100%; left: 0; right: 0;
  background: var(--white); border: 1px solid var(--border);
  border-radius: 6px; z-index: 1000; max-height: 200px;
  overflow-y: auto; box-shadow: var(--shadow-md);
}
.autocomplete-item {
  padding: 10px 14px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--bg2);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg2); color: var(--wine); }
