/* ============================================
   SysLoka - Sistema de Gestão de Locações
   CSS Principal
   ============================================ */

:root {
  --primary: #1a56db;
  --primary-dark: #1e429f;
  --primary-light: #e8f0fe;
  --secondary: #0e9f6e;
  --success: #0e9f6e;
  --danger: #e02424;
  --warning: #ff8800;
  --info: #0694a2;
  --dark: #111928;
  --gray-900: #111928;
  --gray-800: #1f2a37;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50: #f9fafb;
  --white: #ffffff;
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --border-radius: 8px;
  --border-radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.06);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --transition: all 0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  min-height: 100vh;
  display: flex;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- SIDEBAR ---- */
#sidebar {
  width: var(--sidebar-width);
  background: var(--gray-900);
  min-height: 100vh;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
  overflow-y: auto;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: inline-flex;
  align-items: center; justify-content: center;
  font-size: 18px;
  margin-bottom: 10px;
}

.sidebar-logo h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -0.3px;
}

.sidebar-logo p {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gray-500);
  padding: 12px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--gray-400);
  cursor: pointer;
  transition: var(--transition);
  border-radius: 0;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: var(--white);
}

.nav-item.active {
  background: rgba(26, 86, 219, 0.2);
  color: var(--primary);
  border-right: 3px solid var(--primary);
}

.nav-item .nav-icon {
  width: 20px;
  font-size: 15px;
  text-align: center;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: var(--gray-500);
  font-size: 11px;
}

/* ---- MAIN CONTENT ---- */
#main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- TOPBAR ---- */
#topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.topbar-left h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.topbar-left p {
  font-size: 12px;
  color: var(--gray-500);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--border-radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }

.btn-success {
  background: var(--secondary);
  color: var(--white);
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
  background: var(--danger);
  color: var(--white);
}
.btn-danger:hover { opacity: 0.9; }

.btn-warning {
  background: var(--warning);
  color: var(--white);
}
.btn-warning:hover { opacity: 0.9; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

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

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: var(--transition);
}
.btn-icon:hover { background: var(--gray-200); }

/* ---- PAGE CONTENT ---- */
#page-content {
  padding: 24px;
  flex: 1;
}

.page-section { display: none; }
.page-section.active { display: block; }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 20px; }

/* ---- STATS CARDS ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  padding: 20px;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #d1fae5; color: #065f46; }
.stat-icon.yellow { background: #fef3c7; color: #92400e; }
.stat-icon.red { background: #fee2e2; color: #991b1b; }
.stat-icon.purple { background: #ede9fe; color: #5b21b6; }
.stat-icon.cyan { background: #cffafe; color: #155e75; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }

.stat-info h3 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1;
}

.stat-info p {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.stat-info .stat-sub {
  font-size: 11px;
  color: var(--secondary);
  margin-top: 4px;
  font-weight: 500;
}

/* ---- TABLE ---- */
.table-wrapper {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table thead th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

table.data-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition);
}

table.data-table tbody tr:hover { background: var(--gray-50); }

table.data-table tbody td {
  padding: 12px 14px;
  color: var(--gray-700);
  vertical-align: middle;
}

.td-strong { font-weight: 600; color: var(--gray-900) !important; }
.td-muted { font-size: 12px; color: var(--gray-400) !important; }

/* ---- BADGES ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: var(--gray-200); color: var(--gray-600); }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-cyan { background: #cffafe; color: #155e75; }

/* ---- FORMS ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width { grid-column: 1 / -1; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-control {
  padding: 9px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  font-size: 13px;
  color: var(--gray-800);
  background: var(--white);
  transition: var(--transition);
  width: 100%;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.12);
}

.form-control::placeholder { color: var(--gray-400); }

select.form-control { cursor: pointer; }

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

.form-hint {
  font-size: 11px;
  color: var(--gray-400);
}

/* ---- CAMPO CEP COM BUSCA AUTOMÁTICA ---- */
.cep-group { grid-column: span 1; }

.cep-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.cep-input-wrap .form-control {
  padding-right: 36px; /* espaço para o spinner */
  letter-spacing: 0.5px;
}

/* Spinner — visível apenas durante busca */
.cep-spinner {
  position: absolute;
  right: 10px;
  color: var(--gray-400);
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.cep-input-wrap.buscando .cep-spinner  { opacity: 1; color: var(--warning); }
.cep-input-wrap.sucesso  .cep-spinner  { opacity: 1; color: var(--success); }
.cep-input-wrap.sucesso  .cep-spinner .fa-circle-notch { animation: none; }
.cep-input-wrap.sucesso  .cep-spinner::before { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; }
.cep-input-wrap.sucesso  .cep-spinner .fa-circle-notch { display: none; }
.cep-input-wrap.sucesso  .cep-spinner::before { color: var(--success); }
.cep-input-wrap.erro     .cep-spinner  { opacity: 1; color: var(--danger); }
.cep-input-wrap.erro     .cep-spinner .fa-circle-notch { animation: none; display: none; }
.cep-input-wrap.erro     .cep-spinner::before { content: '\f071'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: var(--danger); }

.cep-hint {
  font-size: 11px;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Input CEP: borda colorida conforme estado */
.cep-input-wrap.buscando .form-control { border-color: var(--warning); }
.cep-input-wrap.sucesso  .form-control { border-color: var(--success); box-shadow: 0 0 0 3px rgba(14,159,110,0.12); }
.cep-input-wrap.erro     .form-control { border-color: var(--danger);  box-shadow: 0 0 0 3px rgba(224,36,36,0.10); }

/* Campos preenchidos pelo CEP: animação de destaque */
@keyframes cepFill {
  0%   { background: #d1fae5; }
  100% { background: white; }
}
.cep-filled { animation: cepFill 1.8s ease-out forwards; }

/* ---- MODAL ---- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

.modal-md { max-width: 640px; }
.modal-lg { max-width: 900px; }
.modal-xl { max-width: 1100px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close {
  width: 32px; height: 32px;
  border: none;
  background: var(--gray-100);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-500);
  transition: var(--transition);
}
.modal-close:hover { background: var(--gray-200); color: var(--gray-800); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ---- SECTION HEADER ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
}

.section-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ---- SEARCH BAR ---- */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
}

.search-input-wrapper i {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 13px;
}

.search-input-wrapper .form-control {
  padding-left: 32px;
  min-width: 220px;
}

/* ---- TABS ---- */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  gap: 0;
  overflow-x: auto;
}

.tab-btn {
  padding: 10px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- ALERTS ---- */
.alert {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-400);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.empty-state p { font-size: 13px; }

/* ---- CANVAS ASSINATURA ---- */
.signature-canvas-wrapper {
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius);
  background: var(--gray-50);
  cursor: crosshair;
  position: relative;
}

.signature-canvas-wrapper canvas {
  display: block;
  border-radius: var(--border-radius);
}

.signature-label {
  font-size: 11px;
  color: var(--gray-400);
  text-align: center;
  margin-top: 6px;
}

/* ---- CONTRATO VISUALIZAÇÃO ---- */
.contrato-view {
  font-family: 'Times New Roman', serif;
  font-size: 13px;
  line-height: 1.8;
  padding: 40px;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius);
  max-height: 500px;
  overflow-y: auto;
}

.contrato-view h1 {
  font-size: 16px;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 24px;
}

.contrato-view h2 {
  font-size: 13px;
  text-transform: uppercase;
  margin: 20px 0 8px;
}

.contrato-view p { margin-bottom: 10px; text-align: justify; }

/* ---- DASHBOARD CHARTS ---- */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}

.charts-grid.mb-6 {
  margin-bottom: 24px;
}

/* ---- TIMELINE ---- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 14px;
  padding-bottom: 16px;
  position: relative;
}

.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 17px;
  top: 34px;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.timeline-body {
  flex: 1;
  padding-top: 4px;
}

.timeline-body strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
}

.timeline-body p {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* ---- BOLETO VISUAL ---- */
.boleto-card {
  border: 2px solid var(--gray-300);
  border-radius: var(--border-radius);
  overflow: hidden;
  font-size: 12px;
}

.boleto-header {
  background: var(--gray-900);
  color: white;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
}

.boleto-body { padding: 16px; }

.boleto-row {
  display: flex;
  gap: 20px;
  margin-bottom: 10px;
}

.boleto-field { flex: 1; }
.boleto-field label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--gray-500);
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}
.boleto-field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-900);
}

.boleto-barcode {
  margin-top: 12px;
  padding: 10px;
  background: var(--gray-50);
  border-radius: 4px;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--gray-700);
  border: 1px dashed var(--gray-300);
}

/* ---- QUICK ACTIONS ---- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.quick-action-btn {
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius-lg);
  cursor: pointer;
  text-align: center;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.quick-action-btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.quick-action-btn i {
  font-size: 22px;
  color: var(--primary);
}

.quick-action-btn span {
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-700);
}

/* ---- LOADING ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 10px;
  color: var(--gray-400);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- PROGRESS BAR ---- */
.progress-bar {
  background: var(--gray-200);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 20px;
  transition: width 0.3s ease;
}

/* ---- TOAST NOTIFICATIONS ---- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  min-width: 280px;
  max-width: 380px;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-success { background: #065f46; color: white; }
.toast-danger  { background: #991b1b; color: white; }
.toast-warning { background: #92400e; color: white; }
.toast-info    { background: #1e40af; color: white; }

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #main-wrapper { margin-left: 0; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  #page-content { padding: 16px; }
  .grid-rel { grid-template-columns: 1fr !important; }
}

/* ---- UTILITIES ---- */
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-6 { margin-top: 24px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-6 { margin-bottom: 24px !important; }
.gap-2 { gap: 8px !important; }
.flex { display: flex !important; }
.items-center { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.flex-wrap { flex-wrap: wrap !important; }
.hidden { display: none !important; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-sm { font-size: 12px !important; }
.text-xs { font-size: 11px !important; }
.text-muted { color: var(--gray-400) !important; }
.font-bold { font-weight: 700 !important; }
.font-semibold { font-weight: 600 !important; }
.w-full { width: 100% !important; }
.divider {
  border: none;
  border-top: 1px solid var(--gray-200);
  margin: 20px 0;
}

.action-btns { display: flex; gap: 6px; align-items: center; }

/* ---- CLAUSULAS SELETOR ---- */
.clausulas-list {
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  max-height: 280px;
  overflow-y: auto;
}

.clausula-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.clausula-item:last-child { border-bottom: none; }
.clausula-item:hover { background: var(--gray-50); }

.clausula-item input[type=checkbox] { margin-top: 2px; }
.clausula-item-info h4 { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.clausula-item-info p { font-size: 11px; color: var(--gray-400); }

/* ---- ASSINATURA PAD ---- */
.sig-container {
  border: 2px solid var(--gray-300);
  border-radius: var(--border-radius);
  background: #fafafa;
  position: relative;
}

.sig-container canvas {
  display: block;
  width: 100%;
  cursor: crosshair;
  border-radius: var(--border-radius);
}

.sig-instruction {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: var(--gray-300);
  pointer-events: none;
  text-align: center;
}

.sig-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

/* ---- INDICE CHART ---- */
.indice-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.indice-pill {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  color: var(--gray-600);
  background: white;
}

.indice-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ================================================================
   DASHBOARD EDITOR
   ================================================================ */

/* ── Cards de opção (garantia / modelo pagamento) ── */
.ct-option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 600px) {
  .ct-option-grid { grid-template-columns: 1fr; }
}

.ct-garantia-grid {
  grid-template-columns: 1fr 1fr;
}

.ct-option-card {
  position: relative;
  display: block;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: border-color .18s, background .18s, box-shadow .18s;
  background: white;
  user-select: none;
}

.ct-option-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(14,159,110,.12);
}

.ct-option-card.selected {
  box-shadow: 0 0 0 2px rgba(26, 86, 219, .15);
}

/* ── Seletor multi-pessoa (locadores / fiadores) ── */
.ct-multi-selector {
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
  background: white;
}
.ct-multi-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  min-height: 40px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.ct-multi-chips:empty::before {
  content: attr(data-placeholder);
  font-size: 12px;
  color: var(--gray-400);
  line-height: 26px;
}
.ct-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  background: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  cursor: default;
}
.ct-chip.chip-fiador {
  background: #ede9fe;
  color: #5b21b6;
  border-color: #ddd6fe;
}
.ct-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: inherit;
  opacity: 0.6;
  padding: 0;
  line-height: 1;
}
.ct-chip-remove:hover { opacity: 1; }
.ct-multi-dropdown {
  max-height: 180px;
  overflow-y: auto;
}
.ct-multi-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--gray-700);
  transition: background .12s;
  border-bottom: 1px solid var(--gray-100);
}
.ct-multi-option:last-child { border-bottom: none; }
.ct-multi-option:hover { background: #f0f9ff; }
.ct-multi-option.selected { background: #eff6ff; color: #1a56db; font-weight: 600; }
.ct-multi-option.selected::after { content: '✓'; margin-left: auto; font-weight: 700; }
.ct-multi-option .opt-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #dbeafe;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #1e40af; flex-shrink: 0;
}
.ct-multi-option.opt-fiador .opt-avatar {
  background: #ede9fe; color: #5b21b6;
}
.ct-chip.chip-locatario {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}
.ct-multi-option.opt-locatario .opt-avatar {
  background: #dcfce7; color: #166534;
}
.ct-multi-option.opt-locatario.selected { background: #f0fdf4; color: #166534; }

/* ── Link badge nos KPI cards ── */
.stat-card-link {
  position: absolute;
  bottom: 10px;
  right: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gray-100);
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  transition: background .18s, color .18s, transform .18s;
  pointer-events: none; /* clique vai pro card inteiro */
}

.stat-card[onclick]:hover .stat-card-link {
  background: var(--primary);
  color: white;
  transform: translateX(2px);
}

/* garante que o card com link tenha position relative */
.stat-card[onclick] {
  position: relative;
}

/* ── Barra superior do dashboard ── */
.dash-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}

.dash-edit-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  animation: fadeIn .2s ease;
}

/* ── Banner de orientação ── */
.dash-edit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
  color: #1e40af;
  animation: slideDown .25s ease;
}

.dash-edit-banner i {
  font-size: 16px;
  flex-shrink: 0;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Modo edição ativo ── */
.dash-edit-mode .dash-stats-grid,
#page-dashboard.dash-edit-mode #dash-stats-grid {
  outline: 2px dashed #bfdbfe;
  outline-offset: 6px;
  border-radius: 10px;
}

/* ── Controles por card (visíveis só no modo edição) ── */
.dash-widget {
  position: relative;
}

.dash-remove-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  border: 2px solid white;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  transition: transform .15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  line-height: 1;
}

.dash-remove-btn:hover {
  transform: scale(1.2);
}

.dash-drag-handle {
  position: absolute;
  top: 6px;
  left: 6px;
  color: var(--gray-400);
  font-size: 12px;
  cursor: grab;
  opacity: 0;
  transition: opacity .15s;
}

.dash-widget:hover .dash-drag-handle {
  opacity: 1;
}

.dash-widget[draggable="true"] {
  cursor: grab;
}

/* ── Zona de adição de card ── */
.dash-add-zone {
  border: 2px dashed #bbf7d0 !important;
  background: #f0fdf4 !important;
  cursor: pointer;
  transition: all .2s;
}

.dash-add-zone:hover {
  background: #dcfce7 !important;
  border-color: #0e9f6e !important;
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(14,159,110,.15) !important;
}

/* ── Seções ── */
.dash-section-wrap {
  position: relative;
  margin-bottom: 24px;
}

.dash-section-wrap[draggable="true"] {
  cursor: grab;
}

.dash-section-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 6px 12px;
  font-size: 12px;
  color: #1e40af;
}

.dash-drag-handle-section {
  cursor: grab;
  color: #60a5fa;
  font-size: 13px;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

.dash-drag-handle-section:hover { color: #1d4ed8; }

.dash-remove-section-btn {
  background: none;
  border: 1px solid #fca5a5;
  color: var(--danger);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.dash-remove-section-btn:hover {
  background: #fef2f2;
  border-color: var(--danger);
}

/* Quando seção tem controles, arredonda o card inferior */
.dash-section-controls + .card,
.dash-section-controls + .card.mb-6 {
  border-radius: 0 0 10px 10px;
  margin-bottom: 0 !important;
}

/* ── Zona de adição de seção ── */
.dash-section-add-zone {
  text-align: center;
  padding: 4px 0 8px;
}

.dash-section-add-btn {
  background: none;
  border: 2px dashed #d1d5db;
  color: var(--gray-500);
  border-radius: 10px;
  padding: 14px 32px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font);
  width: 100%;
  transition: all .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.dash-section-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #f0fdf4;
}

/* ── Drag & Drop visual feedback ── */
.drag-source {
  opacity: .4;
  transform: scale(.97);
}

.drag-over {
  outline: 2px dashed var(--primary) !important;
  outline-offset: 4px;
  background: #f0fdf4 !important;
  border-radius: 10px;
}

/* ── Painel lateral de adição ── */
.dash-add-panel {
  position: fixed;
  top: 0;
  right: -360px;
  width: 340px;
  height: 100vh;
  background: white;
  border-left: 1px solid var(--gray-200);
  box-shadow: -8px 0 32px rgba(0,0,0,.12);
  z-index: 1200;
  transition: right .3s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.dash-add-panel.open {
  right: 0;
}

.dash-add-panel-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.dash-add-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  flex-shrink: 0;
}

.dash-add-panel-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.dash-add-panel-close {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: var(--gray-400);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}

.dash-add-panel-close:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.dash-add-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.dash-add-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all .18s;
  background: white;
}

.dash-add-item:hover {
  border-color: var(--primary);
  background: #f0fdf4;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(14,159,110,.1);
}

/* ── Overlay (fecha painel ao clicar fora) ── */
.dash-panel-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.15);
  z-index: 1199;
}

.dash-panel-overlay.show {
  display: block;
}

/* ── Botão de sucesso (modo concluir) ── */
.btn-success {
  background: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
}

.btn-success:hover {
  background: var(--primary-dark) !important;
}

/* ── Responsivo ── */
@media (max-width: 768px) {
  .dash-add-panel {
    width: 100vw;
    right: -100vw;
  }
  .dash-topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .dash-edit-toolbar {
    flex-wrap: wrap;
  }
}
