/* ═══ CorretorTech — App do corretor (PWA) ═══
   Mesmo padrão do visual v2 dos portais (estilo Apple) + materiais de vidro.
   --accent = cor da marca da corretora (aplicada pelo app.js a partir do branding). */
:root {
  --accent: #1F3A6B; --accent-ink: #1F3A6B; --accent-bg: rgb(31 58 107 / .09);
  --on-accent: #FFFFFF;
  --bg: #F5F5F7; --surface: #FFFFFF; --surface-2: #F2F2F7;
  --border: rgb(60 60 67 / .14); --border-light: rgb(60 60 67 / .09);
  --text: #1D1D1F; --muted: rgb(60 60 67 / .74); --faint: #6E6E73;
  --green: #248A3D; --green-bg: rgb(52 199 89 / .14);
  --red: #D70015;   --red-bg: rgb(255 59 48 / .12);
  --yellow: #A04800; --yellow-bg: rgb(255 159 10 / .16);
  --blue: #0066CC;  --blue-bg: rgb(0 122 255 / .12);
  --purple: #8944AB; --purple-bg: rgb(175 82 222 / .12);
  --shadow-sm: 0 1px 2px rgb(0 0 0/.04), 0 2px 8px rgb(0 0 0/.04);
  --shadow-md: 0 1px 2px rgb(0 0 0/.04), 0 4px 12px rgb(0 0 0/.05), 0 16px 40px rgb(0 0 0/.08);
  --mat: rgb(250 250 252 / .72);
  --glass: rgb(255 255 255 / .66); --glass-edge: rgb(255 255 255 / .8);
  --field: #F2F2F7;
  --ease-out: cubic-bezier(.32,.72,0,1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Roboto", "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent-ink: #8FB0FF; --accent-bg: rgb(143 176 255 / .14);
    --bg: #000000; --surface: #1C1C1E; --surface-2: #2C2C2E;
    --border: rgb(255 255 255 / .12); --border-light: rgb(255 255 255 / .08);
    --text: #F5F5F7; --muted: rgb(235 235 245 / .66); --faint: #98989F;
    --green: #30D158; --green-bg: rgb(48 209 88 / .16);
    --red: #FF6961; --red-bg: rgb(255 105 97 / .16);
    --yellow: #FFB340; --yellow-bg: rgb(255 159 10 / .18);
    --blue: #64A8FF; --blue-bg: rgb(100 168 255 / .16);
    --purple: #D29CFF; --purple-bg: rgb(210 156 255 / .16);
    --shadow-sm: 0 0 0 .5px rgb(255 255 255/.07);
    --shadow-md: 0 0 0 .5px rgb(255 255 255/.08), 0 12px 32px rgb(0 0 0/.5);
    --mat: rgb(28 28 30 / .72);
    --glass: rgb(44 44 46 / .55); --glass-edge: rgb(255 255 255 / .08);
    --field: #2C2C2E;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font); font-size: 15px; line-height: 1.4;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
/* Fundo com brilho suave na cor da marca (o "vidro" precisa de algo por trás) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 60% at 0% 0%, color-mix(in srgb, var(--accent) 14%, transparent) 0%, transparent 60%),
    radial-gradient(90% 50% at 100% 25%, color-mix(in srgb, var(--accent) 9%, transparent) 0%, transparent 60%);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 12px; top: calc(var(--safe-top) + 8px); z-index: 999; background: var(--surface); padding: 8px 12px; border-radius: 10px; }

/* ── Topo ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(var(--safe-top) + 8px) 16px 8px;
  background: var(--mat);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 .5px 0 var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-tile {
  width: 32px; height: 32px; flex: none; border-radius: 9px;
  display: grid; place-items: center; color: var(--on-accent);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 80%, #fff), var(--accent));
  box-shadow: inset 0 .5px 0 rgb(255 255 255/.35);
  overflow: hidden;
}
.brand-tile svg { width: 18px; height: 18px; }
.brand-tile img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-name { font-weight: 600; font-size: 17px; letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 999px;
  background: transparent; color: var(--accent-ink);
  display: grid; place-items: center; cursor: pointer;
}
.icon-btn:active { background: var(--accent-bg); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.netbar {
  position: sticky; top: calc(var(--safe-top) + 60px); z-index: 40;
  margin: 8px 16px 0; padding: 8px 12px; border-radius: 12px;
  background: var(--yellow-bg); color: var(--yellow); font-size: 13px; font-weight: 500; text-align: center;
}

/* ── Conteúdo ─────────────────────────────────────────── */
main {
  max-width: 640px; margin: 0 auto;
  padding: 8px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px);
  outline: none;
}
.view { animation: rise .35s var(--ease-out) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .view, .card, .sheet { animation: none !important; transition: none !important; } }

.hello { margin: 14px 2px 18px; }
.hello h1 { margin: 0; font-size: 30px; line-height: 1.1; font-weight: 700; letter-spacing: -.03em; }
.hello p { margin: 6px 0 0; color: var(--muted); font-size: 15px; }
.page-title { margin: 16px 2px 14px; font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }

.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 10px; }
.section-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.section-head a, .link-btn { font-size: 15px; font-weight: 500; text-decoration: none; color: var(--accent-ink); background: none; border: 0; padding: 8px 0; min-height: 44px; cursor: pointer; }

/* Cartões de vidro */
.card {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%); backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--glass-edge);
  border-radius: 20px; box-shadow: var(--shadow-sm);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .card { background: var(--surface); }
}

/* Indicadores */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 4px; min-height: 112px; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.kpi-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent-ink); }
.kpi-ico svg { width: 18px; height: 18px; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi.wide { grid-column: 1 / -1; }
.kpi.hero { background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 88%, #fff), var(--accent)); color: var(--on-accent); border-color: transparent; }
.kpi.hero .kpi-label { color: color-mix(in srgb, var(--on-accent) 80%, transparent); }
.kpi.hero .kpi-ico { background: rgb(255 255 255 / .18); color: var(--on-accent); }
.kpi.hero .kpi-sub { color: color-mix(in srgb, var(--on-accent) 86%, transparent); }
.kpi-sub { font-size: 13px; color: var(--muted); }

/* Selos */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill.red { background: var(--red-bg); color: var(--red); }
.pill.yellow { background: var(--yellow-bg); color: var(--yellow); }
.pill.green { background: var(--green-bg); color: var(--green); }
.pill.blue { background: var(--blue-bg); color: var(--blue); }
.pill.gray { background: rgb(118 118 128 / .14); color: var(--muted); }
.pill.accent { background: var(--accent-bg); color: var(--accent-ink); }

/* Alertas */
.alerts { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.alert { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-decoration: none; color: inherit; min-height: 56px; }
.alert .dot { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.alert .dot svg { width: 18px; height: 18px; }
.alert.red .dot { background: var(--red-bg); color: var(--red); }
.alert.yellow .dot { background: var(--yellow-bg); color: var(--yellow); }
.alert b { display: block; font-size: 15px; font-weight: 600; }
.alert span { font-size: 13px; color: var(--muted); }
.alert .chev { margin-left: auto; color: var(--faint); width: 18px; height: 18px; flex: none; }

/* Funil resumido */
.funnel { padding: 16px; }
.funnel-bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: rgb(118 118 128 / .12); gap: 2px; }
.funnel-bar i { display: block; height: 100%; }
.funnel-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px 12px; margin-top: 14px; }
.funnel-legend a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: inherit; font-size: 14px; min-height: 32px; }
.funnel-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.funnel-legend b { margin-left: auto; font-variant-numeric: tabular-nums; }

/* Listas */
.list { overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; min-height: 60px; text-align: left;
  background: transparent; border: 0; color: inherit; text-decoration: none; cursor: pointer;
}
.row + .row { box-shadow: inset 0 .5px 0 var(--border-light); }
button.row:active, a.row:active { background: rgb(118 118 128 / .08); }
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.row-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row-value { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.avatar { width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--accent-bg); color: var(--accent-ink); }
.chev { width: 18px; height: 18px; color: var(--faint); flex: none; }

/* Tarefas */
.task { align-items: flex-start; cursor: default; }
.check {
  width: 26px; height: 26px; margin: 1px 0 0; flex: none; border-radius: 999px;
  border: 2px solid color-mix(in srgb, var(--muted) 70%, transparent);
  display: grid; place-items: center; background: transparent; cursor: pointer; padding: 0;
  position: relative;
}
.check::after { content: ""; position: absolute; inset: -9px; } /* área de toque 44px */
.check svg { width: 15px; height: 15px; color: var(--on-accent); opacity: 0; transition: opacity .2s; }
.check[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.check[aria-checked="true"] svg { opacity: 1; }
.task.done .row-title { color: var(--muted); text-decoration: line-through; }
.task .row-main { padding-top: 2px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }

/* Controle segmentado e chips */
.segmented { display: flex; padding: 2px; gap: 2px; border-radius: 12px; background: rgb(118 118 128 / .12); margin-bottom: 14px; }
.segmented button { flex: 1; min-height: 36px; border: 0; border-radius: 10px; background: transparent; font-size: 14px; font-weight: 500; cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); font-weight: 600; box-shadow: 0 1px 3px rgb(0 0 0/.12), 0 0 0 .5px rgb(0 0 0/.04); }
@media (prefers-color-scheme: dark) { .segmented button[aria-pressed="true"] { background: #636366; } }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 2px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--glass); box-shadow: var(--shadow-sm); font-size: 14px; font-weight: 500; color: var(--muted);
}
.chip b { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.chip i { width: 8px; height: 8px; border-radius: 99px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.chip[aria-pressed="true"] b { color: var(--on-accent); }

.search {
  display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin-bottom: 12px;
  border-radius: 12px; background: rgb(118 118 128 / .12); color: var(--muted);
}
.search svg { width: 18px; height: 18px; flex: none; }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--text); }

/* Comissões */
.money-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.money { padding: 14px 12px; min-height: 0; }
.money .kpi-value { font-size: 18px; }
.money .kpi-label { font-size: 12px; }

/* Vazio e carregando */
.empty { text-align: center; padding: 32px 20px; color: var(--muted); font-size: 15px; }
.empty svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }
.loading { display: flex; justify-content: center; gap: 6px; padding: 80px 0; }
.loading span { width: 8px; height: 8px; border-radius: 99px; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
.loading span:nth-child(2) { animation-delay: .15s; } .loading span:nth-child(3) { animation-delay: .3s; }
@keyframes pulse { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: none; } }
.skeleton { border-radius: 20px; background: linear-gradient(90deg, rgb(118 118 128/.10), rgb(118 118 128/.18), rgb(118 118 128/.10)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 0 20px; border-radius: 14px; border: 0; cursor: pointer;
  font-size: 16px; font-weight: 600; text-decoration: none; letter-spacing: -.01em;
}
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-tinted { background: var(--accent-bg); color: var(--accent-ink); }
.btn-plain { background: rgb(118 118 128 / .12); color: var(--text); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-block { width: 100%; }
.btn:active { filter: brightness(.94); transform: scale(.99); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.actions .btn { flex-direction: column; gap: 4px; min-height: 64px; font-size: 13px; padding: 8px; }

.fab {
  position: fixed; z-index: 45; right: max(16px, calc(50% - 304px));
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent), 0 2px 6px rgb(0 0 0/.12);
}
.fab svg { width: 26px; height: 26px; }

/* Formulários */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); padding-left: 4px; }
.field input, .field select, .field textarea {
  min-height: 48px; padding: 12px 14px; border-radius: 12px; border: 0;
  background: var(--field); font-size: 16px; outline: none; width: 100%;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { box-shadow: 0 0 0 2px var(--accent-ink); }

/* Detalhes */
.details { padding: 4px 14px; }
.detail { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; font-size: 15px; }
.detail + .detail { box-shadow: inset 0 .5px 0 var(--border-light); }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; font-weight: 500; text-align: right; overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* Perfil */
.profile { display: flex; align-items: center; gap: 14px; padding: 16px; }
.profile .avatar { width: 56px; height: 56px; border-radius: 18px; font-size: 20px; }
.profile b { display: block; font-size: 18px; letter-spacing: -.02em; }
.profile span { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.row-ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none; color: #fff; }
.row-ico svg { width: 18px; height: 18px; }
.foot-note { text-align: center; color: var(--faint); font-size: 12px; margin-top: 28px; }

/* ── Barra inferior ───────────────────────────────────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex; justify-content: space-around;
  padding: 6px 8px calc(var(--safe-bottom) + 6px);
  background: var(--mat);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 -.5px 0 var(--border);
}
.tabbar a {
  position: relative; flex: 1; max-width: 120px; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--faint); font-size: 11px; font-weight: 500; border-radius: 12px;
  transition: color .2s;
}
.tabbar a svg { width: 25px; height: 25px; transition: transform .25s var(--ease-out); }
.tabbar a[aria-current="page"] { color: var(--accent-ink); }
.tabbar a[aria-current="page"] svg { transform: translateY(-1px) scale(1.06); }
.tab-badge {
  position: absolute; top: 4px; left: calc(50% + 6px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
}

/* ── Folha (bottom sheet) ─────────────────────────────── */
.sheet-backdrop { position: fixed; inset: 0; z-index: 80; background: rgb(0 0 0 / .32); animation: fade .25s both; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 90; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto; max-height: calc(100dvh - var(--safe-top) - 24px);
  display: flex; flex-direction: column;
  background: var(--bg); border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 40px rgb(0 0 0 / .18);
  animation: up .4s var(--ease-out) both;
}
@keyframes up { from { transform: translateY(100%); } }
.sheet-grip { width: 38px; height: 5px; border-radius: 99px; background: rgb(118 118 128 / .35); margin: 8px auto 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px 4px 20px; }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; padding: 8px 16px calc(var(--safe-bottom) + 20px); -webkit-overflow-scrolling: touch; }
body.locked { overflow: hidden; }

/* ── Aviso ────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 100; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 20px);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: rgb(29 29 31 / .92); color: #fff; font-size: 14px; font-weight: 500;
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md); animation: rise .3s var(--ease-out) both;
}
@media (prefers-color-scheme: dark) { .toast { background: rgb(242 242 247 / .94); color: #1D1D1F; } }

/* Telas maiores: o app fica centralizado como uma coluna de celular */
@media (min-width: 700px) {
  .tabbar { left: 50%; right: auto; transform: translateX(-50%); width: 640px; border-radius: 20px 20px 0 0; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi.wide { grid-column: span 3; }
}
