/* ============================================================
   Brandalise Imoveis - Captacao CRM
   Identidade: navy profundo + dourado (gestao de propriedades)
   ============================================================ */
:root {
  --navy: #0f2c3f;
  --navy-2: #14384f;
  --navy-3: #1d4a66;
  --gold: #e2b13c;
  --gold-2: #c8952a;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e8ee;
  --text: #1c2b36;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --purple: #8b5cf6;
  --shadow: 0 1px 3px rgba(15,44,63,.08), 0 6px 24px rgba(15,44,63,.06);
  --radius: 12px;
  --radius-sm: 8px;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1,h2,h3,h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- Ambiente banner ---------- */
.env-banner {
  padding: 5px 16px; color: #fff; font-size: 12px; font-weight: 700;
  letter-spacing: .06em; text-align: center; text-transform: uppercase;
}

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--navy); color: #cde0ec; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 20px 20px 14px; display: flex; align-items: center; gap: 11px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, var(--gold), var(--gold-2));
  display: grid; place-items: center; color: var(--navy); font-family: Georgia, serif; font-weight: 700; font-size: 22px;
}
.brand .name { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.1; }
.brand .sub { font-size: 10.5px; color: var(--gold); letter-spacing: .08em; text-transform: uppercase; }
.nav { padding: 8px; display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: #a9c3d4; font-weight: 550; font-size: 13.5px;
}
.nav a:hover { background: var(--navy-2); color: #fff; }
.nav a.active { background: var(--navy-3); color: #fff; }
.nav a .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar .foot { margin-top: auto; padding: 14px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #8fb0c4; }
.sidebar .foot .u-name { color: #fff; font-weight: 600; }
.sidebar .foot .u-papel { color: var(--gold); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.sidebar .foot button {
  margin-top: 8px; width: 100%; background: transparent; border: 1px solid rgba(255,255,255,.18);
  color: #cde0ec; padding: 7px; border-radius: 7px; font-size: 12.5px;
}
.sidebar .foot button:hover { background: var(--navy-2); }
.sidebar .foot .link-troca { display:block; margin-top:8px; color:#8fb0c4; font-size:11.5px; cursor:pointer; text-decoration:underline; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 20px; }
.topbar .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.topbar .acao { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.content { padding: 24px 28px 60px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 9px 15px; border-radius: 9px; font-weight: 600; font-size: 13.5px;
  transition: .12s;
}
.btn:hover { border-color: var(--muted-2); }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy-2); }
.btn.gold { background: var(--gold); border-color: var(--gold-2); color: var(--navy); }
.btn.gold:hover { background: var(--gold-2); }
.btn.danger { color: var(--danger); border-color: #f3c6c6; }
.btn.danger:hover { background: #fdeeee; }
.btn.sm { padding: 6px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .card-h { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card .card-h h3 { font-size: 15px; }
.card .card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .value { font-size: 25px; font-weight: 750; margin-top: 6px; letter-spacing: -.02em; }
.kpi .hint { color: var(--muted-2); font-size: 12px; margin-top: 3px; }
.kpi .stripe { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.kpi.accent-gold .stripe { background: var(--gold); }
.kpi.accent-danger .stripe { background: var(--danger); }
.kpi.accent-navy .stripe { background: var(--navy-3); }
.kpi.accent-ok .stripe { background: var(--ok); }
.kpi.accent-info .stripe { background: var(--info); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; white-space: nowrap; border: 1px solid transparent;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge.soft { background: #eef2f6; color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; padding: 11px 14px; border-bottom: 1px solid var(--border); background: #fafbfc; }
table.tbl td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr.click:hover { background: #f8fafc; cursor: pointer; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters input, .filters select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text);
}
.filters input[type=search] { min-width: 260px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); width: 100%;
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--navy-3); outline-offset: -1px; border-color: var(--navy-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15,44,63,.45); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 640px; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { max-width: 880px; }
.modal .m-h { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal .m-h h3 { font-size: 17px; }
.modal .m-b { padding: 22px; }
.modal .m-f { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; background: var(--surface); }
.x-close { background: transparent; border: none; font-size: 22px; color: var(--muted); line-height: 1; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(1200px 600px at 30% -10%, #17415c, var(--navy)); padding: 20px; }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.35); width: 100%; max-width: 400px; overflow: hidden; }
.login-card .head { background: var(--navy); padding: 30px 30px 24px; color: #fff; text-align: center; }
.login-card .head .logo { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 12px; background: linear-gradient(135deg, var(--gold), var(--gold-2)); display: grid; place-items: center; color: var(--navy); font-family: Georgia, serif; font-size: 30px; font-weight: 700; }
.login-card .head h2 { font-size: 19px; }
.login-card .head p { color: var(--gold); font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; margin: 4px 0 0; }
.login-card .body { padding: 26px 30px 30px; }
.login-card .err { background: #fef2f2; color: #b91c1c; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.login-card .ok { background: #ecfdf5; color: #047857; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.login-hint { margin-top: 16px; font-size: 12px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; }
.login-link { display:block; text-align:center; margin-top:14px; font-size:12.5px; color: var(--navy-3); cursor:pointer; text-decoration:underline; }

/* ---------- Kanban ---------- */
.kanban-wrap { overflow-x: auto; padding-bottom: 12px; }
.kanban { display: flex; gap: 14px; min-height: 60vh; align-items: flex-start; }
.col { background: #eef2f6; border-radius: var(--radius); width: 268px; flex: 0 0 268px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.col.dragover { outline: 2px dashed var(--navy-3); outline-offset: -3px; background: #e6eef4; }
.col .col-h { padding: 12px 14px 8px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; }
.col .col-h .t { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.col .col-h .t .dot { width: 9px; height: 9px; border-radius: 50%; }
.col .col-h .qtd { background: #fff; border: 1px solid var(--border); color: var(--muted); border-radius: 999px; font-size: 11.5px; font-weight: 700; padding: 1px 8px; }
.col .col-b { padding: 4px 10px 12px; overflow-y: auto; display: flex; flex-direction: column; gap: 9px; }
.col .col-val { padding: 0 14px 10px; color: var(--muted); font-size: 11.5px; font-weight: 600; }

.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: 0 1px 2px rgba(15,44,63,.06); cursor: pointer; border-left: 3px solid var(--muted-2); }
.kcard:hover { border-color: var(--navy-3); }
.kcard.arrastavel { cursor: grab; }
.kcard.dragging { opacity: .35; }
/* Fantasma que segue o cursor durante o arraste (pointer events) */
.kcard-fantasma {
  position: fixed; left: 0; top: 0; z-index: 999; pointer-events: none;
  margin: 0 !important; opacity: .97; transform: rotate(2deg);
  box-shadow: 0 16px 36px rgba(15,44,63,.30);
}
body.arrastando { cursor: grabbing; user-select: none; }
body.arrastando .kcard { cursor: grabbing; }
.kcard .end { font-weight: 650; font-size: 13px; line-height: 1.25; }
.kcard .linha { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.kcard .prop { color: var(--text); font-size: 12px; margin-top: 5px; }
.kcard .rodape { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.kcard .valor { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.kcard .dias { color: var(--muted-2); font-size: 11px; }
.kcard .tipo-tag { background:#eef2f6; color: var(--muted); border-radius: 6px; padding: 1px 7px; font-size: 10.5px; font-weight: 600; }
.kcard .docs { font-size: 10.5px; color: var(--muted); }

/* ---------- Detalhe / Abas ---------- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.detail-head .meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; color: var(--muted); font-size: 13px; }
.detail-head .meta b { color: var(--text); font-weight: 600; }
.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs .tab { padding: 10px 16px; font-weight: 600; font-size: 13.5px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--navy); border-bottom-color: var(--gold); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.checklist { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 4px 0 8px; }
.checklist label { display: flex; align-items: center; gap: 9px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; font-size: 13px; font-weight: 550; cursor: pointer; background: var(--surface); }
.checklist label:hover { border-color: var(--muted-2); }
.checklist input { width: 17px; height: 17px; accent-color: var(--navy); }
.checklist label.on { background: #ecfdf5; border-color: #cfe6d9; color: #047857; }

.doc-progress { height: 7px; background: #eef2f6; border-radius: 999px; overflow: hidden; margin-top: 6px; }
.doc-progress .fill { height: 100%; background: var(--ok); border-radius: 999px; }

/* ---------- Timeline (historico) ---------- */
.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before { content: ''; position: absolute; left: 12px; top: 22px; bottom: 0; width: 2px; background: var(--border); }
.tl-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; z-index: 1; }
.tl-body .tl-head { display: flex; justify-content: space-between; gap: 8px; }
.tl-body .who { font-weight: 650; font-size: 13px; }
.tl-body .when { color: var(--muted-2); font-size: 11.5px; white-space: nowrap; }
.tl-body .resumo { margin-top: 3px; font-size: 13.5px; }

.stage-flow { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.stage-flow .step { padding: 6px 11px; border-radius: 8px; font-size: 12px; font-weight: 600; background: #eef2f6; color: var(--muted); border: 1px solid transparent; cursor: pointer; }
.stage-flow .step.active { color: #fff; }
.stage-flow .step:hover { border-color: var(--navy-3); }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty .big { font-size: 34px; margin-bottom: 8px; }

.bars { display: flex; flex-direction: column; gap: 11px; }
.bars .bar-row { display: grid; grid-template-columns: 150px 1fr 96px; align-items: center; gap: 10px; font-size: 12.5px; }
.bars .track { background: #eef2f6; border-radius: 6px; height: 22px; overflow: hidden; }
.bars .fill { height: 100%; border-radius: 6px; min-width: 2px; }
.bars .bval { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }

.spinner { width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--navy); border-radius: 50%; animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 22px; right: 22px; background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow); z-index: 100; font-size: 13.5px; opacity: 0; transform: translateY(10px); transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: var(--danger); }

.section-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 22px 0 10px; }
.hint-box { font-size: 12.5px; color: var(--muted); background: #f8fafc; border: 1px dashed var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 14px; }
.busca-result { border:1px solid var(--border); border-radius: 10px; margin-top: 8px; overflow:hidden; }
.busca-result .r { padding: 10px 12px; border-bottom: 1px solid var(--border); display:flex; justify-content:space-between; gap:10px; cursor:pointer; }
.busca-result .r:last-child { border-bottom:none; }
.busca-result .r:hover { background:#f8fafc; }

@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .nav { flex-direction: row; margin: 0; }
  .sidebar .foot { margin: 0 0 0 auto; border: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .kpis { grid-template-columns: 1fr; }
  .form-row, .form-row-3, .checklist { grid-template-columns: 1fr; }
}
