/* Tokens de layout: grade de 4/8pt, 4 tamanhos de fonte, 2 pesos. */
:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 16px; --fs-lg: 24px;
  --fw: 400; --fw-b: 600;
  --r-sm: 12px; --r-md: 16px; --r-lg: 24px;
  --tap: 44px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

/* Cores: 60% neutro, 30% texto/escuro, 10% acento. */
:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #eceff5;
  --text: #171b26;
  --muted: #566075;
  --border: #dfe3ec;
  --accent: #1f4e79;
  --accent-2: #2e75b6;
  --accent-text: #ffffff;
  --seller: #e6edf8;
  --client: #1f4e79;
  --client-text: #ffffff;
  --ok: #1d7a46;
  --warn: #8f5a00;
  --danger: #b3261e;
  --chip: #dde7f3;
  --chip-limited: #fbe9d0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(31, 78, 121, .06), 0 8px 24px rgba(31, 78, 121, .08);
  color-scheme: light;
}

/* Tema: Automático segue o sistema; data-theme="light"/"dark" (botão do topo) força um dos dois. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101319;
    --surface: #1a1e27;
    --surface-2: #242936;
    --text: #e8eaf0;
    --muted: #a3abbd;
    --border: #2f3544;
    --accent: #6ea8e0;
    --accent-2: #8fbdea;
    --accent-text: #0d1522;
    --seller: #232c3b;
    --client: #2e5d8c;
    --client-text: #ffffff;
    --ok: #5fcf8e;
    --warn: #f0b659;
    --danger: #ff8a80;
    --chip: #263447;
    --chip-limited: #45351d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
    --bg: #101319;
    --surface: #1a1e27;
    --surface-2: #242936;
    --text: #e8eaf0;
    --muted: #a3abbd;
    --border: #2f3544;
    --accent: #6ea8e0;
    --accent-2: #8fbdea;
    --accent-text: #0d1522;
    --seller: #232c3b;
    --client: #2e5d8c;
    --client-text: #ffffff;
    --ok: #5fcf8e;
    --warn: #f0b659;
    --danger: #ff8a80;
    --chip: #263447;
    --chip-limited: #45351d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: var(--fw) var(--fs-md)/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
strong, h1, h2, h3 { font-weight: var(--fw-b); }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

.app {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-inline: 1px solid var(--border);
}
.boot { padding: var(--sp-7) var(--sp-4); color: var(--muted); }

/* Ícones */
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 18px; height: 18px; }
.icon.lg { width: 32px; height: 32px; }

/* Topo */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  min-height: 56px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: var(--fs-md); margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { font-weight: var(--fw-b); color: var(--accent); }
.topbar .lang-select { width: auto; flex: none; }
.lang-select { min-height: 36px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: var(--r-sm); padding: var(--sp-1) var(--sp-2); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-b); }
.iconbtn {
  flex: none; width: var(--tap); height: var(--tap); margin: -4px 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; text-decoration: none;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.iconbtn:hover, .iconbtn.active { background: var(--surface-2); color: var(--accent); }
.topbar .logo { flex: none; display: block; width: 32px; height: 32px; line-height: 0; }
.topbar .logo { width: 38px; height: 38px; padding: 3px; border-radius: var(--r-sm); background: #e8f1ff; box-shadow: 0 0 0 1px var(--border); }
.topbar .logo svg { width: 100%; height: 100%; display: block; }

main { flex: 1; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-4); animation: rise .25s var(--ease); }
main.chat-main { padding: 0; gap: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Navegação inferior */
.bottomnav {
  position: sticky; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(6, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding: var(--sp-1) var(--sp-1) calc(var(--sp-1) + env(safe-area-inset-bottom));
}
.bottomnav a {
  min-height: 56px; padding: var(--sp-1) 0; text-align: center; font-size: var(--fs-xs); color: var(--muted); text-decoration: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-radius: var(--r-sm);
}
.bottomnav a .pill { display: flex; align-items: center; justify-content: center; width: 100%; max-width: 56px; height: 28px; border-radius: 99px; transition: background .2s var(--ease), color .2s var(--ease); }
.bottomnav a.active { color: var(--accent); font-weight: var(--fw-b); }
.bottomnav a.active .pill { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* Blocos */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); box-shadow: var(--shadow); }
.card h2, .card h3 { margin: 0 0 var(--sp-2); font-size: var(--fs-md); }
.muted { color: var(--muted); font-size: var(--fs-sm); }
.small { font-size: var(--fs-xs); }
.row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.pre { white-space: pre-wrap; word-break: break-word; }
.ficha { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--r-sm); padding: var(--sp-3); font-size: var(--fs-sm); }
.list-item { display: flex; flex-direction: column; gap: var(--sp-1); text-decoration: none; color: inherit; cursor: pointer; transition: transform .15s var(--ease), border-color .15s var(--ease); }
.list-item:hover { border-color: var(--accent-2); }
.list-item:active { transform: scale(.985); }
details.card summary { min-height: var(--tap); display: flex; align-items: center; flex-wrap: wrap; column-gap: var(--sp-1); }

/* Formulários */
label { display: flex; flex-direction: column; gap: var(--sp-1); font-size: var(--fs-sm); font-weight: var(--fw-b); }
label.check { flex-direction: row; align-items: flex-start; gap: var(--sp-2); font-weight: var(--fw); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], textarea, select {
  width: 100%; min-height: 48px; font: inherit; font-weight: var(--fw); color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-3);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { resize: vertical; min-height: 96px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 28%, transparent); }
input[type=checkbox], input[type=radio] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }
.hint { font-weight: var(--fw); color: var(--muted); font-size: var(--fs-xs); }
.counter { text-align: right; font-weight: var(--fw); color: var(--muted); font-size: var(--fs-xs); }

.segmented { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-2); }
.segmented button { min-height: var(--tap); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-sm); cursor: pointer; transition: background .15s var(--ease), border-color .15s var(--ease); }
.segmented button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: var(--fw-b); }

button.btn, a.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: var(--sp-2);
  min-height: 48px; padding: var(--sp-3) var(--sp-5); border-radius: var(--r-md); border: 1px solid transparent;
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: var(--fw-b); cursor: pointer; text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), 0 4px 12px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform .12s var(--ease), box-shadow .15s var(--ease), opacity .15s;
}
button.btn:active, a.btn:active { transform: scale(.97); }
button.btn.secondary, a.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); box-shadow: none; }
button.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); box-shadow: none; }
.card.danger-zone { border-color: var(--danger); margin-top: var(--sp-6); }
.card.danger-zone h3 { color: var(--danger); }
button.btn.danger:disabled { opacity: .45; cursor: not-allowed; }
button.btn.link, a.btn.link { background: none; color: var(--accent); min-height: var(--tap); padding: var(--sp-2) 0; font-weight: var(--fw-b); align-self: flex-start; box-shadow: none; }
button.btn.block { width: 100%; }
/* Envio do formulário sempre ao alcance do polegar, acima da navegação inferior. */
form.card.stack > button.btn.block[type=submit]:last-child { position: sticky; bottom: 72px; z-index: 2; }
input[type=file] { font: inherit; font-size: var(--fs-sm); color: var(--muted); width: 100%; }
input[type=file]::file-selector-button { min-height: var(--tap); margin-right: var(--sp-3); padding: var(--sp-2) var(--sp-4); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-2); color: var(--text); font: inherit; font-weight: var(--fw-b); cursor: pointer; }
button.btn:disabled { opacity: .55; cursor: progress; }

.badge { display: inline-block; font-size: var(--fs-xs); font-weight: var(--fw-b); padding: 2px var(--sp-2); border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.aprovado { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.em_esclarecimento, .badge.ficha_pronta { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.badge.limitada { background: var(--chip-limited); color: var(--warn); }

.issues { border: 1px solid var(--danger); border-radius: var(--r-sm); padding: var(--sp-3) var(--sp-4); background: color-mix(in srgb, var(--danger) 10%, transparent); color: var(--text); font-size: var(--fs-sm); }
.issues ul { margin: var(--sp-2) 0 0; padding-left: var(--sp-4); }
.error { color: var(--danger); font-size: var(--fs-sm); }
[aria-invalid="true"] { outline: 2px solid var(--danger); outline-offset: 2px; border-radius: var(--r-sm); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }

/* Fotos */
.thumbs { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.thumb { position: relative; width: 88px; height: 88px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; inset: auto 0 0 0; min-height: 28px; border: 0; background: rgba(0, 0, 0, .62); color: #fff; font-size: var(--fs-xs); padding: var(--sp-1); cursor: pointer; }
.thumb-label { position: absolute; top: var(--sp-1); left: var(--sp-1); background: rgba(0, 0, 0, .65); color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-b); padding: 0 var(--sp-2); border-radius: 8px; }

/* Chat */
.chat-head { padding: var(--sp-3) var(--sp-4); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--sp-1); }
.chat-log { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); }
.bubble { max-width: 86%; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); white-space: pre-wrap; word-break: break-word; animation: pop .22s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.bubble .who { display: block; font-size: var(--fs-xs); font-weight: var(--fw-b); opacity: .75; margin-bottom: var(--sp-1); }
.bubble.vendedor { align-self: flex-start; background: var(--seller); border-bottom-left-radius: 4px; }
.bubble.cliente { align-self: flex-end; background: var(--client); color: var(--client-text); border-bottom-right-radius: 4px; box-shadow: 0 4px 12px color-mix(in srgb, var(--client) 30%, transparent); }
.chips { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }
.chip { position: relative; border: 0; border-radius: 99px; min-height: 28px; padding: var(--sp-1) var(--sp-3); font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-b); background: var(--chip); color: var(--text); cursor: pointer; }
.chip::after { content: ''; position: absolute; inset: -8px -2px; } /* amplia a área de toque */
.chip.limitada { background: var(--chip-limited); }
.typing { align-self: flex-start; display: inline-flex; gap: var(--sp-1); align-items: center; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); background: var(--seller); color: var(--muted); font-size: var(--fs-sm); }
.typing::after { content: ''; width: 24px; height: 6px; background: radial-gradient(circle, var(--muted) 2.5px, transparent 3px) 0 50%/8px 6px repeat-x; animation: dots 1s steps(4) infinite; }
@keyframes dots { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }
.composer { position: sticky; bottom: 0; padding: var(--sp-3); background: var(--surface); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: var(--sp-2); padding-bottom: calc(var(--sp-3) + env(safe-area-inset-bottom)); }
.composer textarea { min-height: 52px; max-height: 160px; }
.row.nowrap { flex-wrap: nowrap; align-items: flex-end; }
.grow { flex: 1; min-width: 0; }
fieldset.price { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4) var(--sp-4); margin: 0; min-width: 0; }
fieldset.price legend { font-size: var(--fs-sm); font-weight: var(--fw-b); padding: 0 var(--sp-1); }
label.currency { width: 96px; flex: none; }
h2.section { font-size: var(--fs-md); margin: var(--sp-3) 0 0; color: var(--accent); }
.campaign { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-3); border: 1px solid var(--border); border-radius: var(--r-sm); }
.badge.vigente { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.agendada { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.chip.objection { background: color-mix(in srgb, var(--warn) 20%, transparent); cursor: default; }
.chip.scope { background: color-mix(in srgb, var(--accent) 14%, transparent); cursor: default; padding: 2px var(--sp-2); }
.chip.objection::after, .chip.scope::after { content: none; }
.warn { color: var(--warn); }
details summary { cursor: pointer; }
.bubble .row { margin-top: var(--sp-2); }
.bubble .btn.small { min-height: 36px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); border-radius: 99px; box-shadow: none; }
.bubble .btn.link.small { font-size: var(--fs-xs); padding: var(--sp-1) 0; }
.feedback-list { display: flex; flex-direction: column; gap: var(--sp-1); margin-top: var(--sp-2); }
.feedback-list:empty { display: none; }
.feedback-form { margin-top: var(--sp-2); }
.feedback-form textarea { min-height: 64px; }
.reported { color: var(--danger); font-weight: var(--fw-b); }
.reported-body summary { font-size: var(--fs-xs); color: var(--danger); font-weight: var(--fw-b); }
.modal .segmented { grid-template-columns: 1fr 1fr; }
.bubble.replaced { opacity: .6; font-size: var(--fs-sm); border: 1px dashed var(--border); background: transparent; }
.bubble.replaced summary { font-size: var(--fs-xs); font-weight: var(--fw-b); }
.banner { margin: var(--sp-3); padding: var(--sp-3) var(--sp-4); border-radius: var(--r-sm); background: var(--surface-2); font-size: var(--fs-sm); }
.clarify { margin: var(--sp-3); border: 2px solid var(--warn); }

/* Modal como bottom sheet */
.modal-back { position: fixed; inset: 0; background: rgba(8, 12, 20, .5); display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade .2s ease; }
.modal { position: relative; width: 100%; max-width: 440px; max-height: 88dvh; overflow-y: auto; background: var(--surface); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--sp-5) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: var(--sp-3); animation: sheet .28s var(--ease); }
.modal::before { content: ''; position: absolute; top: var(--sp-2); left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 99px; background: var(--border); }
.modal h2 { margin: 0; font-size: var(--fs-md); }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
/* Saldo de créditos no topo */
#creditbanner:empty { display: none; }
#creditbanner .banner { display: block; margin: 0; }
.creditchip { display: inline-flex; align-items: center; min-height: 28px; padding: 0 var(--sp-3); border-radius: 99px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: var(--fs-xs); font-weight: var(--fw-b); text-decoration: none; white-space: nowrap; }
.creditchip.baixo { border-color: var(--warn); color: var(--warn); }
.creditchip.critico, .creditchip.zero, .creditchip.sem_plano { border-color: var(--danger); color: var(--danger); }
/* Painel de administrador */
.app.wide { max-width: 1100px; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data th, table.data td { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; white-space: nowrap; }
table.data th { color: var(--muted); font-size: var(--fs-xs); font-weight: var(--fw-b); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
.stat { display: flex; flex-direction: column; gap: var(--sp-1); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-3) var(--sp-4); }
.stat strong { font-size: var(--fs-lg); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--sp-3); }
.daybars { display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.daybar { flex: 1; min-width: 3px; background: var(--accent-2); border-radius: 2px 2px 0 0; }
.daybar.alert { background: var(--danger); }
.bar { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent-2); border-radius: 99px; }
.brk { display: grid; grid-template-columns: minmax(80px, 1fr) 2fr auto; gap: var(--sp-3); align-items: center; font-size: var(--fs-sm); }
.meter.warn > span { background: var(--warn); }
ul.plain { margin: 0; padding-left: var(--sp-4); }
table.cost { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); }
table.cost th, table.cost td { padding: var(--sp-2) var(--sp-1); border-bottom: 1px solid var(--border); text-align: right; }
table.cost th:first-child, table.cost td:first-child { text-align: left; }

.toast { position: fixed; left: 50%; bottom: 88px; transform: translate(-50%, 8px); max-width: 400px; width: calc(100% - 32px); background: #1e2330; color: #fff; padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md); font-size: var(--fs-sm); box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s var(--ease); z-index: 30; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); color: #fff; }
.hidden { display: none !important; }

/* Início */
.hero { position: relative; overflow: hidden; border-radius: var(--r-lg); padding: var(--sp-5) var(--sp-4); text-align: center; color: #e8f1ff;
  background: radial-gradient(circle at 50% 0%, #1b46b0 0%, #0a2158 55%, #050f2c 100%); box-shadow: var(--shadow); }
.hero::before { content: ''; position: absolute; inset: 0; opacity: .18; pointer-events: none;
  background-image: linear-gradient(#38bdf8 1px, transparent 1px), linear-gradient(90deg, #38bdf8 1px, transparent 1px); background-size: 32px 32px; }
.hero > * { position: relative; }
.hero .hero-logo { display: block; width: 96px; height: 96px; margin: 0 auto var(--sp-2); line-height: 0; filter: drop-shadow(0 0 16px rgba(56, 189, 248, .5)); }
.hero .hero-logo svg { width: 100%; height: 100%; }
.hero h2 { margin: 0; font-size: var(--fs-lg); }
.hero-tag { margin: var(--sp-1) 0; font-size: var(--fs-sm); }
.hero-pillars { margin: 0 0 var(--sp-4); font-size: var(--fs-xs); color: #ffb35c; }
.hero .btn { background: #fff; color: #0a2158; box-shadow: 0 8px 20px rgba(0, 0, 0, .3); }
.resume { display: flex; align-items: center; gap: var(--sp-3); }
.resume .grow { display: flex; flex-direction: column; }
.ico-tile { flex: none; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.home-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.home-card { display: flex; flex-direction: column; gap: var(--sp-2); padding: var(--sp-4); border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: transform .15s var(--ease); }
.home-card:active { transform: scale(.97); }
.home-card .ico-tile { background: color-mix(in srgb, #38bdf8 18%, transparent); }
.home-card:nth-child(even) .ico-tile { background: color-mix(in srgb, #ff8a1f 18%, transparent); color: var(--warn); }
.home-card .small { color: var(--muted); }
.badge.goal { background: color-mix(in srgb, #38bdf8 20%, transparent); color: var(--accent); }
.badge.ok { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }
.badge.no { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.outcome select { width: auto; min-height: 36px; display: inline-block; font-size: var(--fs-xs); padding: var(--sp-1) var(--sp-2); }
.diag { margin-top: var(--sp-2); border-left: 3px solid #ff8a1f; padding-left: var(--sp-3); }
.diag summary { cursor: pointer; font-weight: var(--fw-b); }
.diag p { margin: var(--sp-1) 0 0; }

/* Estados vazios e carregamento */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: var(--sp-6) var(--sp-4); text-align: center; border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .ico-tile { width: 64px; height: 64px; border-radius: 50%; }
.empty p { margin: 0; max-width: 28ch; }
.skeleton { height: 72px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface) 50%, var(--surface-2) 75%) 0 0/200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Login: logo grande e campo de senha com botão de mostrar/ocultar */
.auth-logo { display: block; width: 96px; height: 96px; margin: var(--sp-2) auto 0; line-height: 0; filter: drop-shadow(0 0 16px rgba(56, 189, 248, .35)); }
.auth-logo svg { width: 100%; height: 100%; display: block; }
.center { text-align: center; }
.credit { display: flex; align-items: center; justify-content: center; gap: var(--sp-1); margin: var(--sp-3) 0 0; font-size: var(--fs-xs); color: var(--muted); opacity: .8; }
.credit img { width: 16px; height: 16px; display: block; }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { padding-right: calc(var(--tap) + var(--sp-1)); }
.pw-toggle { position: absolute; top: 50%; right: var(--sp-1); margin: 0; transform: translateY(-50%); }

/* Treino (plano Plus) */
.home-card.wide { grid-column: 1 / -1; margin-bottom: var(--sp-3); }
.bubble.me { align-self: flex-end; background: var(--client); color: var(--client-text); border-bottom-right-radius: 4px; box-shadow: 0 4px 12px color-mix(in srgb, var(--client) 30%, transparent); }
.bubble.them { align-self: flex-start; background: var(--seller); border-bottom-left-radius: 4px; }
.chat-log.static { overflow: visible; padding: var(--sp-3) 0 0; }
.chip.pick { background: var(--surface-2); border: 1px solid var(--border); min-height: 36px; padding: var(--sp-1) var(--sp-3); }
.chip.pick.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.meter { display: inline-block; width: 64px; height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; vertical-align: middle; }
.meter > span { display: block; height: 100%; border-radius: 99px; background: var(--accent-2); }
.dim .meter { display: block; width: 100%; height: 8px; }
.chip.interest { display: inline-flex; align-items: center; gap: var(--sp-2); }
.chip.interest .meter { width: 40px; }
.score { display: flex; align-items: baseline; gap: var(--sp-1); }
.score strong { font-size: 48px; line-height: 1; color: var(--accent); }
.quote { margin: var(--sp-1) 0 0; padding-left: var(--sp-3); border-left: 3px solid var(--border); font-style: italic; }
.upsell .bullets { margin: 0; padding-left: var(--sp-5); display: flex; flex-direction: column; gap: var(--sp-2); }
.upsell h2 { margin: 0; font-size: var(--fs-md); }

/* Chat acompanha a área visível: com o teclado aberto o campo de digitação fica logo acima dele. */
.app:has(.chat-main) { height: var(--vvh, 100dvh); min-height: 0; overflow: hidden; transform: translateY(var(--vvt, 0px)); }
.app:has(.chat-main) main { min-height: 0; overflow-y: auto; }
.app:has(.chat-main) .chat-log { min-height: 0; }
html.kb-open .app:has(.chat-main) .bottomnav { display: none; }

/* Botão de layout: em telas muito estreitas some do topo (a escolha continua na Conta). */
@media (max-width: 519px) { .layout-btn { display: none; } }

/* PWA: faixa para instalar o app (botão no Android, instrução no iPhone). */
.pc-install {
  position: fixed; inset-inline: var(--sp-3); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow); padding: var(--sp-3) var(--sp-4); max-width: 520px; margin-inline: auto;
}
.pc-install p { margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.pc-install-acoes { display: flex; gap: var(--sp-2); justify-content: flex-end; }
.pc-install button { min-height: var(--tap); padding: 0 var(--sp-4); border-radius: 999px; font: inherit; font-size: var(--fs-sm); cursor: pointer; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.pc-install .pc-install-botao { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: var(--fw-b); }
/* ===== Layout de computador (escolhido pelo usuário ou automático em telas de 900 px ou mais) =====
   O layout de celular segue as regras acima, sem alteração. */
html[data-layout="computador"] .app { max-width: 1280px; }
html[data-layout="computador"] .app.wide { max-width: 1440px; }
html[data-layout="computador"] .app:not(:has(> .bottomnav)) { max-width: 560px; }

/* Com navegação: menu lateral fixo à esquerda e conteúdo à direita. */
html[data-layout="computador"] .app:has(> .bottomnav) {
  display: grid; grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: auto 1fr;
  grid-template-areas: "nav top" "nav main"; align-items: start;
}
html[data-layout="computador"] .app:has(> .bottomnav) > .topbar { grid-area: top; }
html[data-layout="computador"] .app:has(> .bottomnav) > main { grid-area: main; min-width: 0; align-self: stretch; padding: var(--sp-5) var(--sp-6); }
html[data-layout="computador"] .app:has(> .bottomnav) > main.chat-main { padding: 0; }
html[data-layout="computador"] .bottomnav {
  grid-area: nav; align-self: start; position: sticky; top: 0; height: 100dvh; z-index: 6;
  display: flex; flex-direction: column; gap: var(--sp-1);
  padding: var(--sp-5) var(--sp-3);
  background: var(--surface); border-top: 0; border-right: 1px solid var(--border);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
html[data-layout="computador"] .bottomnav a {
  flex-direction: row; justify-content: flex-start; gap: var(--sp-3);
  min-height: 44px; padding: var(--sp-2) var(--sp-3); font-size: var(--fs-sm); text-align: left;
}
html[data-layout="computador"] .bottomnav a .pill { width: 36px; max-width: none; flex: none; }

/* Conteúdo mais largo: formulários com largura confortável, listas e painéis em colunas. */
html[data-layout="computador"] main > form.card.stack { width: 100%; max-width: 760px; align-self: center; }
html[data-layout="computador"] form.card.stack > button.btn.block[type=submit]:last-child { bottom: var(--sp-4); }
html[data-layout="computador"] main .stack:has(> .list-item) { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); align-items: start; }
html[data-layout="computador"] .home-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Chat centralizado, com bolhas mais estreitas em relação à largura. */
html[data-layout="computador"] .chat-head,
html[data-layout="computador"] .chat-log,
html[data-layout="computador"] .composer { width: 100%; max-width: 860px; margin-inline: auto; }
html[data-layout="computador"] .bubble { max-width: 70%; }

/* Janelas e avisos: caixa no centro da tela, sem a folha inferior. */
html[data-layout="computador"] .modal-back { align-items: center; padding: var(--sp-4); }
html[data-layout="computador"] .modal { max-width: 560px; max-height: 86dvh; border-radius: var(--r-lg); }
html[data-layout="computador"] .modal::before { display: none; }
html[data-layout="computador"] .toast { bottom: var(--sp-5); }

/* Janela estreita no layout de computador: o menu lateral vira uma faixa só de ícones. */
@media (max-width: 700px) {
  html[data-layout="computador"] .app:has(> .bottomnav) { grid-template-columns: 64px minmax(0, 1fr); }
  html[data-layout="computador"] .app:has(> .bottomnav) > main { padding: var(--sp-4); }
  html[data-layout="computador"] .bottomnav { padding-inline: var(--sp-1); align-items: center; }
  html[data-layout="computador"] .bottomnav a { justify-content: center; gap: 0; width: 100%; padding-inline: 0; font-size: 0; }
  html[data-layout="computador"] .bottomnav a .pill { width: 44px; }
}
