/* ============================================================
   SISTEMAVICO v2 - Estilos customizados
   Complementa Tailwind via CDN
   ============================================================ */

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e7e5e4;
  --border-soft: #f1f0ee;
  --text: #1c1917;
  --text-muted: #78716c;
  --text-soft: #a8a29e;

  --jb: #3b82f6;
  --jb-soft: #eff6ff;
  --jb-text: #1e40af;

  --vc: #8b5cf6;
  --vc-soft: #f5f3ff;
  --vc-text: #6d28d9;

  --vl: #f97316;
  --vl-soft: #fff7ed;
  --vl-text: #c2410c;

  --success: #10b981;
  --success-soft: #ecfdf5;
  --danger: #ef4444;
  --danger-soft: #fef2f2;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ----- Layout principal ----- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.main {
  padding: 28px 36px;
  max-width: 1400px;
  width: 100%;
}

/* ----- Logo / brand ----- */
.brand {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 10px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text);
}

/* ----- Seletor de empresa (chips no topo da sidebar) ----- */
.empresa-switcher {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}

.empresa-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s ease;
}

.empresa-chip:hover {
  background: var(--bg);
  color: var(--text);
}

.empresa-chip.ativa {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
}

.empresa-chip .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.empresa-chip[data-empresa="geral"] .dot { background: #44403c; }
.empresa-chip[data-empresa="jb_valor"] .dot { background: var(--jb); }
.empresa-chip[data-empresa="valor_concierge"] .dot { background: var(--vc); }
.empresa-chip[data-empresa="valoc"] .dot { background: var(--vl); }

/* ----- Nav da sidebar ----- */
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  padding: 14px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease;
}

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
}

.nav-item.ativa {
  background: var(--bg);
  color: var(--text);
  font-weight: 500;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  stroke-width: 1.8;
}

/* ----- Headings ----- */
.page-title {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 24px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

/* ----- Cards ----- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
}

.card-flush {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}

/* ----- KPI cards ----- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.kpi-value.neg { color: var(--danger); }
.kpi-value.pos { color: var(--success); }

/* ----- Linhas de pagamento ----- */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-soft);
  gap: 12px;
}

.row:last-child {
  border-bottom: none;
}

.row-main {
  flex: 1;
  min-width: 0;
}

.row-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.row-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.row.paga .row-title > span:first-child {
  color: var(--text-soft);
  text-decoration: line-through;
}

.row.paga .row-value {
  color: var(--text-muted);
}

.row-value {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

/* ----- Badges ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-jb { background: var(--jb-soft); color: var(--jb-text); }
.badge-vc { background: var(--vc-soft); color: var(--vc-text); }
.badge-vl { background: var(--vl-soft); color: var(--vl-text); }
.badge-pago { background: var(--success-soft); color: #047857; }
.badge-atraso { background: var(--danger-soft); color: #b91c1c; }
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-parcial { background: #dbeafe; color: #1e40af; }

/* ----- Botões ----- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg);
  border-color: #d6d3d1;
}

.btn-primary {
  background: var(--text);
  color: white;
  border-color: var(--text);
}

.btn-primary:hover {
  background: #292524;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg);
}

.btn-icon {
  padding: 6px;
  width: 30px;
  height: 30px;
  justify-content: center;
}

.btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2;
}

/* ----- Barra de progresso ----- */
.progress {
  flex: 1;
  height: 6px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--jb);
  transition: width 0.3s ease;
}

/* ----- Modal ----- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: 14px;
  max-width: 480px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
}

.modal-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 18px;
}

/* ----- Inputs ----- */
.field {
  margin-bottom: 14px;
}

.field-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: block;
}

.input, .select, .textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: border-color 0.12s ease;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--text);
}

.textarea {
  resize: vertical;
  min-height: 80px;
}

/* ----- Empty state ----- */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ----- Login ----- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 380px;
}

/* ----- Responsivo simples ----- */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: relative;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .main {
    padding: 20px;
  }
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
