:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface2: #f9fafb;
  --border: #e5e7eb;
  --border2: #d1d5db;
  --sidebar-bg: #111827;
  --sidebar-text: #9ca3af;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #1a56db;
  --sidebar-hover: #1f2937;
  --accent: #1a56db;
  --accent-hover: #1e429f;
  --accent-light: #eff6ff;
  --accent-light2: #dbeafe;
  --gold: #d97706;
  --text: #111827;
  --text2: #374151;
  --muted: #6b7280;
  --muted2: #9ca3af;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --success: #16a34a;
  --success-bg: #f0fdf4;
  --success-border: #bbf7d0;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Modo escuro — redefine as mesmas variáveis de cor, então qualquer elemento
   do site que já usa var(--xxx) se adapta automaticamente, sem precisar editar
   cada página uma por uma. ── */
body[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #20242f;
  --border: #2d3140;
  --border2: #3a3f52;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-light: rgba(59,130,246,.15);
  --accent-light2: rgba(59,130,246,.28);
  --gold: #f59e0b;
  --text: #e5e7eb;
  --text2: #cbd5e1;
  --muted: #9ca3af;
  --muted2: #6b7280;
  --danger: #f87171;
  --danger-bg: rgba(248,113,113,.12);
  --danger-border: rgba(248,113,113,.3);
  --success: #4ade80;
  --success-bg: rgba(74,222,128,.12);
  --success-border: rgba(74,222,128,.3);
  --warn: #fbbf24;
  --warn-bg: rgba(251,191,36,.12);
  --warn-border: rgba(251,191,36,.3);
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -1px rgba(0,0,0,.3);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -2px rgba(0,0,0,.3);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.5; transition: background .2s, color .2s; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .logo {
  width: 40px; height: 40px;
  background: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  padding: 4px;
  overflow: hidden;
}
.sidebar-brand .logo img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand .brand-name { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: 11px; color: var(--sidebar-text); }

.nav-section { padding: 16px 12px 8px; }
.nav-section-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: #4b5563; padding: 0 8px; margin-bottom: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all .15s;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e5e7eb; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background .15s;
}
.sidebar-user:hover { background: var(--sidebar-hover); }
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; color: #f9fafb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--sidebar-text); }

.main { margin-left: 240px; flex: 1; padding: 32px; min-height: 100vh; max-width: calc(100vw - 240px); }

/* ── Page header ── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 28px; gap: 16px; }
.page-header-left h1 { font-size: 22px; font-weight: 700; letter-spacing: -.4px; color: var(--text); }
.page-header-left .subtitle { font-size: 13px; color: var(--muted); margin-top: 3px; }
.page-header-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 16px;
}
.card + .card { margin-top: 20px; }

/* ── Stat cards ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.stat-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; margin-bottom: 14px; }
.stat-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--muted); font-weight: 500; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600;
  cursor: pointer; border: none;
  transition: all .15s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text2); border: 1px solid var(--border2); }
.btn-secondary:hover { background: var(--surface2); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }
.btn-danger:hover { background: #fee2e2; }
.btn-success { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600;
}
.badge-blue { background: var(--accent-light2); color: var(--accent); }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: var(--danger-bg); color: var(--danger); }
.badge-green { background: var(--success-bg); color: var(--success); }
.badge-gray { background: #f3f4f6; color: var(--muted); border: 1px solid var(--border); }
.badge-orange { background: #fff7ed; color: #c2410c; }
.badge-pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 16px; }
label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}
textarea { resize: vertical; min-height: 90px; }
select option { background: var(--surface); }
.form-hint { font-size: 12px; color: var(--muted2); margin-top: 5px; }
.form-separator { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.required { color: var(--danger); margin-left: 2px; }

/* ── Alerts ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13.5px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 10px; }
.alert-error { background: var(--danger-bg); border: 1px solid var(--danger-border); color: #991b1b; }
.alert-success { background: var(--success-bg); border: 1px solid var(--success-border); color: #166534; }
.alert-warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: #92400e; }
.alert-info { background: var(--accent-light); border: 1px solid var(--accent-light2); color: #1e40af; }

/* ── Table ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; padding: 12px 16px; background: var(--surface2); border-bottom: 1px solid var(--border); }
td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; color: var(--text2); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface2); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 24px; backdrop-filter: blur(2px); }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 28px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); scrollbar-width: thin; scrollbar-color: var(--border2, #d1d5db) transparent; }
.modal::-webkit-scrollbar { width: 8px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--border2, #d1d5db); border-radius: 999px; border: 2px solid var(--surface); }
.modal::-webkit-scrollbar-thumb:hover { background: var(--muted, #9ca3af); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.modal-header h2 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--border); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ── Upgrade Modal (estilo e-mail) ── */
.upgrade-overlay { position: fixed; inset: 0; background: rgba(17,24,39,.55); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 20px; backdrop-filter: blur(3px); animation: upgradeFadeIn .18s ease-out; }
.upgrade-card { background: var(--surface); border-radius: 18px; max-width: 440px; width: 100%; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.25); animation: upgradePopIn .25s cubic-bezier(.34,1.56,.64,1); }
.upgrade-header { background: linear-gradient(135deg,#4f46e5,#7c3aed); padding: 32px 28px 26px; text-align: center; position: relative; }
.upgrade-header .upgrade-close { position: absolute; top: 14px; right: 14px; background: rgba(255,255,255,.15); border: none; color: #fff; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: background .15s; }
.upgrade-header .upgrade-close:hover { background: rgba(255,255,255,.28); }
.upgrade-icon { font-size: 42px; margin-bottom: 8px; }
.upgrade-header h2 { color: #fff; font-size: 19px; font-weight: 800; margin: 0 0 6px; }
.upgrade-header p { color: rgba(255,255,255,.85); font-size: 13.5px; margin: 0; line-height: 1.5; }
.upgrade-body { padding: 26px 28px 28px; }
.upgrade-body p { color: var(--text2); font-size: 14px; line-height: 1.6; margin: 0 0 16px; text-align: center; }
.upgrade-features { background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 20px; }
.upgrade-features div { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text2); padding: 5px 0; }
.upgrade-btn { display: block; width: 100%; background: linear-gradient(135deg,#4f46e5,#7c3aed); color: #fff; text-decoration: none; padding: 13px 24px; border-radius: 10px; font-weight: 700; font-size: 14.5px; text-align: center; border: none; cursor: pointer; transition: transform .15s, box-shadow .15s; box-shadow: 0 4px 14px rgba(79,70,229,.35); }
.upgrade-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79,70,229,.45); }
.upgrade-secondary { display: block; text-align: center; margin-top: 12px; font-size: 13px; color: var(--muted); background: none; border: none; cursor: pointer; text-decoration: underline; }
@keyframes upgradeFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes upgradePopIn { from { opacity: 0; transform: scale(.92) translateY(8px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ── Tabs ── */
.tabs { display: flex; gap: 2px; background: var(--bg); border-radius: 10px; padding: 3px; width: fit-content; margin-bottom: 22px; border: 1px solid var(--border); }
.tab { padding: 8px 18px; font-size: 13px; font-weight: 500; cursor: pointer; border-radius: 8px; color: var(--muted); transition: all .15s; border: none; background: none; font-family: var(--font); }
.tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Lot card ── */
.lot-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all .15s;
  box-shadow: var(--shadow);
}
.lot-card:hover { border-color: var(--accent); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.lot-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.lot-card-addr { font-weight: 600; font-size: 14.5px; color: var(--text); line-height: 1.35; }
.lot-card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.lot-card-vals { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.lot-val { font-size: 13px; font-weight: 600; color: var(--text); }
.lot-val-label { font-size: 11px; color: var(--muted); margin-bottom: 2px; }

/* ── Detail fields ── */
.field-row { display: flex; justify-content: space-between; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--border); gap: 16px; }
.field-row:last-child { border-bottom: none; }
.field-label { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.field-value { font-size: 13px; font-weight: 500; text-align: right; color: var(--text); }

/* ── Score semáforo ── */
.score-box { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-radius: var(--radius-lg); font-weight: 600; font-size: 14px; margin-bottom: 18px; }
.score-verde { background: var(--success-bg); border: 1.5px solid var(--success-border); color: #166534; }
.score-amarelo { background: var(--warn-bg); border: 1.5px solid var(--warn-border); color: #92400e; }
.score-vermelho { background: var(--danger-bg); border: 1.5px solid var(--danger-border); color: #991b1b; }
.score-icon { font-size: 24px; }

/* ── Checklist ── */
.check-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.check-item:last-child { border-bottom: none; }
.check-item input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--accent); flex-shrink: 0; margin-top: 2px; }
.check-label { font-size: 13.5px; font-weight: 500; color: var(--text2); }
.check-note { font-size: 12px; color: var(--muted); margin-top: 3px; cursor: pointer; }
.check-note:hover { color: var(--accent); }
.check-judicial { font-size: 10px; background: #fef3c7; color: #92400e; padding: 1px 7px; border-radius: 99px; font-weight: 600; margin-left: 8px; }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 14px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--muted); }

/* ── Notification ── */
.notif-item { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .12s; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: var(--accent-light); }
.notif-dot { width: 9px; height: 9px; background: var(--accent); border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.notif-dot.read { background: var(--border2); }
.notif-text { font-size: 13px; color: var(--text2); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--muted2); margin-top: 3px; }

/* ── Viab table ── */
.viab-table th, .viab-table td { padding: 9px 12px; }
.viab-neg td { color: var(--danger); background: var(--danger-bg) !important; }
.viab-neg td:hover { background: #fee2e2 !important; }

/* ── Foto ── */
.foto-upload { border: 2px dashed var(--border2); border-radius: var(--radius-lg); padding: 24px; text-align: center; cursor: pointer; transition: all .15s; background: var(--surface2); }
.foto-upload:hover { border-color: var(--accent); background: var(--accent-light); }
.foto-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.foto-wrap { position: relative; }
.foto-thumb { width: 90px; height: 68px; object-fit: cover; border-radius: 8px; border: 1.5px solid var(--border); }
.foto-del { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 11px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* ── Utility ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

/* ── Lightbox ── */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 2000; display: none; align-items: center; justify-content: center; cursor: zoom-out; }
#lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 10px; box-shadow: var(--shadow-lg); }

/* ── Navegação mobile (menu "hambúrguer") ──────────────────────────────────
   Até agora o sidebar era sempre fixo em 240px, o que em telas de celular
   (geralmente 360-430px de largura) deixava quase sem espaço pro conteúdo.
   Abaixo de 860px, o sidebar passa a ficar escondido por padrão, abrindo só
   quando a pessoa toca no botão de menu, e o conteúdo principal ocupa a tela
   inteira normalmente. */
.mobile-menu-btn {
  display: none;
  position: fixed; top: 14px; left: 14px; z-index: 200;
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--sidebar-bg); color: #fff; border: none;
  font-size: 20px; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 99;
}
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; max-width: 100vw; padding: 64px 16px 32px; }
  .mobile-menu-btn { display: flex; }
  .sidebar-overlay.open { display: block; }
}
