/* ============ MetaAds Studio — premium light ============ */
:root {
  --bg: #fafaf8;
  --surface: #ffffff;
  --border: #e8e4df;
  --border-soft: #f0ede8;
  --text: #1a1714;
  --muted: #8c8480;
  --accent: #0f766e;
  --accent-soft: #eef6f4;
  --accent-dark: #0b5b55;
  --danger: #b91c1c;
  --danger-soft: #fdf0ef;
  --warn-bg: #fdf6e9;
  --warn-border: #ecd9b0;
  --warn-text: #7a5a1e;
  --ok: #15803d;
  --radius: 14px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Figtree', system-ui, sans-serif;
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-card: 0 1px 2px rgba(26, 23, 20, 0.04);
  --shadow-lift: 0 8px 24px rgba(26, 23, 20, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.65;
}
.hidden { display: none !important; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 1.7rem; line-height: 1.2; }
h3 { font-size: 1.12rem; margin-bottom: 0.7rem; }
em { font-style: italic; }

a { color: var(--accent); }
code { background: var(--accent-soft); padding: 1px 6px; border-radius: 6px; font-size: 0.85em; }

/* ---------- login ---------- */
.login-screen {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(60rem 30rem at 80% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  padding: 24px;
}
.login-box {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 36px;
  text-align: center;
  box-shadow: var(--shadow-lift);
  animation: rise 400ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
.login-mark { font-size: 2.4rem; color: var(--accent); line-height: 1; margin-bottom: 12px; }
.login-box h1 { font-size: 1.7rem; margin-bottom: 6px; }
.login-box p { color: var(--muted); font-size: 0.92rem; margin-bottom: 26px; }
.login-box input { margin-bottom: 12px; text-align: center; }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 26px 16px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh; height: 100dvh;
}
.brand {
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 600;
  color: var(--accent);
  padding: 0 10px;
  letter-spacing: -0.02em;
}
.brand span { color: var(--text); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 0.95rem; font-weight: 500;
  color: var(--muted);
  padding: 10px 12px; border-radius: 10px;
  text-align: left;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.nav-ico { width: 20px; text-align: center; font-size: 1rem; }
.sidebar-foot {
  margin-top: auto;
  font-size: 0.75rem; color: var(--muted);
  padding: 0 10px;
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}

main {
  flex: 1; min-width: 0;
  padding: 36px 44px 80px;
  max-width: 980px;
}

.view { animation: rise 300ms cubic-bezier(0.4, 0, 0.2, 1) both; }
.view-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 26px; flex-wrap: wrap;
}
.view-sub { color: var(--muted); font-size: 0.92rem; margin-top: 2px; }
.view-head.sub-head { margin: 34px 0 18px; padding-top: 24px; border-top: 1px solid var(--border-soft); }
.view-head.sub-head h2 { font-size: 1.15rem; }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- primitives ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}
.card.help { background: var(--bg); box-shadow: none; }
.card.help ol { padding-left: 20px; display: grid; gap: 8px; font-size: 0.92rem; }

label { display: block; font-size: 0.85rem; font-weight: 600; margin: 12px 0 5px; }
label:first-child { margin-top: 0; }
.hint { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
p.hint { margin: 8px 0 14px; }

input, textarea, select {
  width: 100%;
  font-family: var(--font-body); font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 13px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; }

.btn {
  font-family: var(--font-body); font-size: 0.92rem; font-weight: 600;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; cursor: pointer;
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.ghost:hover:not(:disabled) { border-color: var(--muted); }
.btn.danger { background: none; border-color: var(--border); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.wide { width: 100%; }
.btn.small { padding: 6px 12px; font-size: 0.82rem; }

.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 160px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.switch-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 0.95rem; font-weight: 500; margin-bottom: 6px; cursor: pointer;
}
.switch-label input { width: auto; accent-color: var(--accent); transform: scale(1.25); }

.banner {
  border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 20px;
  font-size: 0.92rem;
}
.banner.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); color: var(--warn-text); }
.banner.danger { background: #fdeceb; border: 1px solid #f2b8b3; color: #8c2119; }
.banner.ok { background: var(--accent-soft); border: 1px solid var(--accent); color: var(--accent-dark); }
.banner a { color: inherit; font-weight: 600; }

/* checagem pré-voo: os mesmos banners, empilhados — 14/18px + 20px de margem é grande
   demais quando são cinco avisos seguidos dentro do card do plano */
.preflight:not(:empty) { margin: 4px 0 16px; }
.preflight .banner { padding: 10px 14px; margin-bottom: 8px; font-size: 0.85rem; line-height: 1.45; }
.preflight .banner strong { display: block; margin-bottom: 3px; }
.preflight .pf-saida { margin-top: 5px; opacity: 0.85; font-style: italic; }
.preflight .hint { margin-top: -2px; }

/* frase de origem: não é aviso, é explicação — por isso barra lateral em vez de banner colorido.
   A frase em si vira balão de conversa: dá para entender o recurso sem ler o texto. */
.origin-tip {
  border-left: 3px solid var(--accent);
  background: var(--bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 10px 14px; margin-top: 12px;
  font-size: 0.85rem; line-height: 1.45;
}
.origin-tip strong { display: block; margin-bottom: 4px; }
.origin-tip .hint { margin-top: 6px; display: block; }
/* na lista de campanhas o espaço é apertado: só a frase, sem explicação (vai no title) */
.camp-origin { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.camp-origin span { color: var(--accent-dark); background: var(--accent-soft); padding: 1px 7px; border-radius: 99px; }

.origin-phrase {
  display: inline-block; margin: 7px 0 1px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  color: var(--accent-dark); font-weight: 500;
  padding: 7px 12px; border-radius: 12px 12px 3px 12px;
}

/* medidor de limite/saldo — a barra que faltava para "R$ X de R$ Y usados" */
.meter { height: 10px; border-radius: 99px; background: var(--border); overflow: hidden; margin: 4px 0 10px; }
.meter-fill { height: 100%; background: var(--accent); transition: width var(--t-base); }
.meter-fill.hot { background: var(--danger); }
.meter-legend {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 0.9rem; color: var(--muted); margin-bottom: 16px;
}
.meter-legend strong { color: var(--text); }
.error-msg { color: var(--danger); font-size: 0.88rem; margin-top: 10px; min-height: 1.2em; }
.ok-msg { color: var(--ok); font-size: 0.88rem; margin-top: 10px; }

.empty {
  text-align: center; color: var(--muted);
  padding: 48px 20px; font-size: 0.95rem;
  border: 1px dashed var(--border); border-radius: var(--radius);
}

/* ---------- painel ---------- */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px;
}
.stat .num { font-family: var(--font-display); font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }
.stat .num.small { font-size: 1.05rem; }
.stat .lbl { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; }

.campaign-list { display: grid; gap: 16px; }
.camp {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 22px;
  box-shadow: var(--shadow-card);
  transition: transform var(--t-base), box-shadow var(--t-base);
  animation: rise 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
.camp:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.camp-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.camp-name { font-family: var(--font-display); font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; }
.camp-sub { font-size: 0.83rem; color: var(--muted); margin-top: 2px; }
.badge {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 4px 10px; border-radius: 99px; text-transform: uppercase;
  flex-shrink: 0;
}
.badge.active { background: var(--accent-soft); color: var(--accent-dark); }
.badge.paused { background: var(--warn-bg); color: var(--warn-text); }
.badge.observe { background: var(--border); color: var(--muted); }
.camp-badges { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px; margin: 16px 0 14px;
  padding: 14px 16px; background: var(--bg); border-radius: 10px;
}
.metric .v { font-weight: 700; font-size: 1.02rem; }
.metric .k { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.camp-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.experiment-box {
  margin: 0 0 14px; padding: 12px 14px;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 10px;
}
.experiment-head { font-size: 0.78rem; font-weight: 700; color: var(--accent-dark); text-transform: uppercase; letter-spacing: 0.05em; }
.experiment-variants { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.experiment-variants .pill { display: inline-flex; align-items: center; gap: 6px; }
.experiment-note { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }

/* ---------- chat ---------- */
.chat-shell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
  height: calc(100dvh - 210px);
  min-height: 420px;
  overflow: hidden;
}
.chat-scroll {
  flex: 1; overflow-y: auto;
  padding: 26px 24px;
  display: flex; flex-direction: column; gap: 14px;
  scroll-behavior: smooth;
}
.msg {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  animation: rise 250ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
.msg.ai {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-bottom-left-radius: 6px;
}
.msg.user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.typing { display: flex; gap: 5px; align-items: center; padding: 16px 18px; }
.msg.typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); display: block;
  animation: blink 1.2s infinite;
}
.msg.typing i:nth-child(2) { animation-delay: 0.2s; }
.msg.typing i:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

.chips { display: flex; gap: 8px; flex-wrap: wrap; align-self: flex-start; animation: rise 300ms both; }
.chip {
  font-family: var(--font-body); font-size: 0.84rem; font-weight: 500;
  background: var(--surface); color: var(--accent-dark);
  border: 1px solid var(--border); border-radius: 99px;
  padding: 7px 14px; cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

/* sub-abas do 2º nível de navegação */
.subnav { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; }
.chip.active { border-color: var(--accent); background: var(--accent); color: #fff; }

.chat-input-row {
  display: flex; gap: 10px; align-items: flex-end;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input-row textarea {
  border: none; box-shadow: none; padding: 10px 6px;
  max-height: 130px; background: transparent;
}
.chat-input-row textarea:focus { box-shadow: none; }
.btn.send { border-radius: 12px; padding: 10px 16px; font-size: 1rem; flex-shrink: 0; }
@keyframes mic-pulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.45); }
  70% { box-shadow: 0 0 0 12px rgba(15, 118, 110, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0); }
}

/* ---------- assistente (Jarvis) ---------- */
.jarvis-shell { display: flex; flex-direction: column; gap: 16px; }
.jarvis-orb-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 0 2px; }
.jarvis-orb {
  position: relative; width: 88px; height: 88px; border-radius: 50%;
  border: none; cursor: pointer; flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, var(--accent-soft), var(--surface) 72%);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-card);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.9rem;
  transition: transform var(--t-base), background var(--t-base), color var(--t-base);
  animation: jarvis-idle 3.4s ease-in-out infinite;
}
.jarvis-orb:hover { transform: translateY(-2px); }
.jarvis-orb-ring {
  position: absolute; inset: -9px; border-radius: 50%;
  border: 1.5px solid var(--accent-soft);
  transition: border-color var(--t-base);
}
.jarvis-orb.listening {
  background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-dark) 75%);
  color: #fff;
  animation: mic-pulse 1.2s ease-out infinite;
}
.jarvis-orb.listening .jarvis-orb-ring { border-color: var(--accent); }
@keyframes jarvis-idle {
  0%, 100% { box-shadow: 0 0 0 1px var(--border), var(--shadow-card); }
  50% { box-shadow: 0 0 0 1px var(--border), 0 0 0 9px var(--accent-soft), var(--shadow-card); }
}
.jarvis-status {
  font-family: var(--font-display); font-style: italic;
  font-size: 0.92rem; color: var(--muted); letter-spacing: -0.01em;
}
.jarvis-chat { height: calc(100dvh - 400px); min-height: 300px; }
@media (max-width: 720px) { .jarvis-chat { height: calc(100dvh - 430px); } }

/* ---------- jarvis — widget flutuante global ---------- */
.jarvis-widget { position: fixed; right: 28px; bottom: 28px; z-index: 60; display: flex; flex-direction: column; align-items: flex-end; gap: 14px; }
.jarvis-fab {
  position: relative; width: 60px; height: 60px; border-radius: 50%;
  border: none; cursor: pointer; flex-shrink: 0;
  background: radial-gradient(circle at 35% 30%, var(--accent-soft), var(--surface) 72%);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-lift);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  transition: transform var(--t-base), background var(--t-base), color var(--t-base);
}
.jarvis-fab:hover { transform: translateY(-2px); }
.jarvis-fab-ring {
  position: absolute; inset: -6px; border-radius: 50%;
  border: 1.5px solid transparent;
  transition: border-color var(--t-base);
}
.jarvis-fab.armed .jarvis-fab-ring { border-color: var(--accent-soft); animation: jarvis-idle 3.4s ease-in-out infinite; }
.jarvis-fab.open { background: radial-gradient(circle at 35% 30%, var(--accent), var(--accent-dark) 75%); color: #fff; }
.jarvis-panel {
  width: 380px; max-width: calc(100vw - 48px);
  height: 560px; max-height: calc(100dvh - 140px);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lift);
  display: flex; flex-direction: column; overflow: hidden;
  animation: rise 220ms cubic-bezier(0.4, 0, 0.2, 1) both;
}
.jarvis-panel.hidden { display: none; }
.jarvis-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0;
}
.jarvis-panel-title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.jarvis-panel .jarvis-shell { flex: 1; min-height: 0; padding: 0 16px 16px; overflow-y: auto; }
.jarvis-panel .jarvis-orb-wrap { padding: 10px 0 2px; }
.jarvis-panel .jarvis-orb { width: 64px; height: 64px; font-size: 1.4rem; }
.jarvis-panel .jarvis-chat { height: 320px; min-height: 0; flex-shrink: 0; }
@media (max-width: 780px) {
  .jarvis-widget { right: 16px; bottom: calc(64px + env(safe-area-inset-bottom) + 14px); }
  .jarvis-panel {
    position: fixed; right: 16px; left: 16px;
    bottom: calc(64px + env(safe-area-inset-bottom) + 88px);
    width: auto; height: calc(100dvh - 64px - env(safe-area-inset-bottom) - 168px);
  }
}

/* plano dentro do chat */
.plan-card {
  align-self: stretch;
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  overflow: hidden;
  animation: rise 300ms both;
}
.plan-head {
  background: var(--accent-soft);
  padding: 14px 18px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.plan-head .t { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--accent-dark); }
.plan-body { padding: 16px 18px; }
.plan-summary { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.pill {
  font-size: 0.8rem; font-weight: 600;
  background: var(--bg); border: 1px solid var(--border-soft);
  padding: 5px 11px; border-radius: 99px;
}
.plan-copy { background: var(--bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; font-size: 0.9rem; }
.plan-copy .h { font-weight: 700; }
.plan-copy .d { color: var(--muted); font-size: 0.83rem; }

/* preview do anúncio — mockup de feed */
.preview-label {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 8px;
}
.ad-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 14px;
  max-width: 440px;
  box-shadow: var(--shadow-card);
}
.ad-head { display: flex; align-items: center; gap: 9px; padding: 11px 13px 8px; }
.ad-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700;
}
.ad-page { font-weight: 700; font-size: 0.88rem; line-height: 1.2; }
.ad-sponsored { color: var(--muted); font-size: 0.75rem; }
.ad-text { padding: 0 13px 10px; font-size: 0.88rem; white-space: pre-wrap; }
.ad-image {
  background: var(--bg);
  aspect-ratio: 1 / 1;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 0.85rem; text-align: center; padding: 10px;
  border-top: 1px solid var(--border-soft); border-bottom: 1px solid var(--border-soft);
}
.ad-image.has { padding: 0; }
.ad-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 13px; background: #f5f4f1;
}
.ad-foot-info { min-width: 0; }
.ad-domain { color: var(--muted); font-size: 0.7rem; letter-spacing: 0.05em; }
.ad-headline { font-weight: 700; font-size: 0.88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-desc { color: var(--muted); font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-cta {
  flex-shrink: 0;
  background: #25d366; color: #fff;
  font-weight: 700; font-size: 0.82rem;
  padding: 8px 13px; border-radius: 7px;
}
details.plan-edit { border-top: 1px solid var(--border-soft); padding-top: 10px; margin-bottom: 12px; }
details.plan-edit summary {
  cursor: pointer; font-size: 0.86rem; font-weight: 600; color: var(--accent-dark);
  list-style: none;
}
details.plan-edit summary::before { content: '▸ '; }
details.plan-edit[open] summary::before { content: '▾ '; }
.plan-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.plan-fields .full { grid-column: 1 / -1; }
.plan-fields label { margin: 0 0 3px; font-size: 0.78rem; }
.plan-publish { display: grid; gap: 10px; border-top: 1px solid var(--border-soft); padding-top: 14px; }
.file-drop {
  border: 1.5px dashed var(--border);
  border-radius: 10px; padding: 14px;
  text-align: center; font-size: 0.88rem; color: var(--muted);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.file-drop:hover, .file-drop.has { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }
.file-drop input { display: none; }

.image-choice-row { display: flex; gap: 10px; align-items: stretch; }
.image-choice-row .file-drop { flex: 1; display: flex; align-items: center; justify-content: center; }
.image-choice-row .btn { flex-shrink: 0; }

/* ---------- galeria de imagens ---------- */
.gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px; margin-top: 4px;
}
.gallery-thumb {
  display: block;
  aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden;
  border: 2px solid var(--border-soft); cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.gallery-thumb:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.gallery-thumb.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gallery-grid-lg {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px; margin-top: 4px;
}

.upload-drop {
  display: flex; align-items: center; justify-content: center;
  border: 1.5px dashed var(--border);
  border-radius: 10px; padding: 26px;
  text-align: center; font-size: 0.92rem; font-weight: 500; color: var(--muted);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.upload-drop:hover { border-color: var(--accent); color: var(--accent-dark); background: var(--accent-soft); }
.upload-drop input { display: none; }

/* ---------- números ---------- */
.number-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px; border-top: 1px solid var(--border-soft);
  gap: 10px;
}
.number-item .np { color: var(--muted); font-size: 0.88rem; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(26, 23, 20, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--surface); border-radius: var(--radius);
  width: 100%; max-width: 620px; max-height: 82vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lift);
  animation: rise 250ms both;
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
#modal-body { padding: 16px 20px; overflow-y: auto; }
.log-item { border-bottom: 1px solid var(--border-soft); padding: 12px 0; font-size: 0.88rem; }
.log-item .when { color: var(--muted); font-size: 0.78rem; }
.log-item .act { font-weight: 700; }
.log-item .act.increase_budget { color: var(--ok); }
.log-item .act.decrease_budget { color: var(--warn-text); }
.log-item .act.pause { color: var(--danger); }
.log-item .act.error { color: var(--danger); }
details.self-check { margin-top: 6px; }
details.self-check summary {
  cursor: pointer; list-style: none;
  font-size: 0.8rem; font-weight: 600; color: var(--accent-dark);
}
details.self-check summary::before { content: '▸ '; }
details.self-check[open] summary::before { content: '▾ '; }
.self-check .qa { margin: 8px 0 0 12px; padding-left: 10px; border-left: 2px solid var(--accent-soft); }
.self-check .q { font-size: 0.8rem; font-weight: 600; }
.self-check .a { font-size: 0.8rem; color: var(--muted); }
.self-check ul { margin: 8px 0 0 12px; padding-left: 10px; border-left: 2px solid var(--accent-soft); list-style: none; }
.self-check ul li { font-size: 0.82rem; color: var(--muted); padding: 2px 0; }

/* ---------- Top ações de hoje ----------
   O numeral grande é a única decoração do card, e é funcional: a ordem é a informação principal.
   A faixa colorida à esquerda diz a urgência sem precisar de ícone nem de mais uma cor de texto. */
.actions-card { border-left: 3px solid var(--accent); }
.acoes { list-style: none; display: flex; flex-direction: column; gap: 14px; }
.acao { border-left: 3px solid var(--border); padding: 2px 0 2px 14px; }
.acao.critico { border-left-color: var(--danger); }
.acao.aviso { border-left-color: var(--warn-border); }
.acao.oportunidade { border-left-color: var(--ok); }
.acao.base { border-left-color: var(--border); }
.acao-top { display: flex; gap: 12px; align-items: flex-start; }
.acao-n {
  font-family: var(--font-display); font-size: 1.9rem; line-height: 1;
  color: var(--muted); opacity: 0.45; min-width: 28px;
}
.acao-cab { flex: 1; }
.acao-cab .pill { font-size: 0.7rem; letter-spacing: 0.06em; text-transform: uppercase; }
.acao-title { font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; }
.acao-money { font-size: 0.86rem; margin-top: 2px; }
.acao-money strong { color: var(--accent-dark); font-size: 1.02rem; }
.acao-money span { color: var(--muted); }
.acao-money.vazio strong { color: var(--muted); }
.acao-body { font-size: 0.9rem; color: var(--muted); margin: 6px 0 0 40px; }
.acao details.self-check, .acao .btn { margin-left: 40px; }
.acao .btn { margin-top: 8px; }

/* ---------- gráficos (public/chart.js) ----------
   O SVG tem largura fixa de 720 no viewBox e width:100% aqui — escala sem distorcer o texto.
   Cor vem de `--c`, definida inline por gráfico, para o mesmo componente servir gasto (petróleo),
   alerta (vermelho) e conversas sem precisar de uma classe por cor. */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--border-soft); stroke-width: 1; }
.chart .ax {
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  fill: var(--muted); letter-spacing: 0.02em;
}
.chart .line { fill: none; stroke: var(--c, var(--accent)); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--c, var(--accent)); opacity: 0.09; }
.chart .dot { fill: var(--c, var(--accent)); }
.chart .bar { fill: var(--c, var(--accent)); opacity: 0.8; transition: opacity var(--t-fast); }
.chart .bar:hover { opacity: 1; }
/* faixa do período sem coleta: listrada de propósito, para não ser lida como "período com zero" */
.chart .gap {
  fill: var(--border-soft);
  opacity: 0.7;
}
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover { fill: var(--accent-soft); opacity: 0.55; }
.chart.mini { width: 120px; margin-top: 6px; }
.chart.mini .line { stroke-width: 1.5; }

.chart-card { padding: 18px 20px 12px; }
.chart-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 12px; flex-wrap: wrap; margin-bottom: 6px;
}
.chart-head h3 {
  font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; letter-spacing: -0.01em;
}
.chart-head .sub { font-size: 0.8rem; color: var(--muted); }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); }
.chart-legend i {
  display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  background: var(--accent); margin-right: 5px; vertical-align: middle; font-style: normal;
}
.chart-legend i.gap { background: var(--border-soft); border: 1px solid var(--border); }

.rank-row + .rank-row { margin-top: 2px; }
.rank .meter-legend { margin-bottom: 2px; font-size: 0.86rem; }
.rank .meter-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 68%; }
.rank .meter-legend em { color: var(--muted); font-style: normal; font-size: 0.78rem; }
.rank .meter { margin: 0 0 12px; }

/* grade de gráficos: 2 colunas no desktop, 1 no mobile (a regra de coluna única está lá embaixo) */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 22px; }

/* Variação contra a janela anterior.
   A SETA diz a direção (subiu/desceu) e a COR diz se isso é bom — os dois não são a mesma coisa:
   custo por conversa subindo é ▲ vermelho. Inverter a seta para "ficar verde" seria mentir sobre
   o número para deixar o painel bonito. */
.delta {
  font-family: var(--font-body); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.02em; vertical-align: middle; margin-left: 4px;
  padding: 2px 6px; border-radius: 99px; white-space: nowrap;
}
.delta.up { color: var(--ok); background: #eaf6ee; }
.delta.down { color: var(--danger); background: var(--danger-soft); }
.delta.flat { color: var(--muted); background: var(--border-soft); }

/* título de seção fora de card — separa "Hoje" de "Histórico" sem criar mais uma caixa */
h3.secao {
  font-family: var(--font-display); font-size: 1.25rem; font-weight: 600;
  letter-spacing: -0.02em; margin: 26px 0 12px;
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
}
h3.secao .hint { font-family: var(--font-body); font-size: 0.78rem; }

/* dentro de um card os stats já têm a borda do card em volta — a segunda borda vira ruído */
.stats-row.tight { gap: 10px; margin: 12px 0 4px; }
.stats-row.tight .stat { background: transparent; border: 0; padding: 4px 0; }
.stats-row.tight .stat .num { font-size: 1.35rem; }

/* declaração do horário de atendimento — mora dentro do card do Painel, ao lado do número que ela destrava */
.atd-form { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.atd-form .chip { display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.atd-form .chip input { accent-color: var(--accent); margin: 0; }
.atd-horas { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.atd-horas label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; color: var(--muted); }
.atd-horas input[type="time"] {
  font-family: var(--font-body); font-size: 0.88rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
}
.atd-horas input[type="time"]:focus { outline: none; border-color: var(--accent); }

/* ---------- mobile ---------- */
@media (max-width: 780px) {
  .app { flex-direction: column; }

  /* sidebar vira barra de navegação fixa no rodapé */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 40;
    width: 100%; height: auto;
    flex-direction: column; gap: 0;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    border-right: none; border-top: 1px solid var(--border);
    box-shadow: 0 -2px 16px rgba(26, 23, 20, 0.06);
  }
  .brand, .sidebar-foot { display: none; }
  .sidebar nav { flex-direction: row; gap: 0; width: 100%; }
  /* já coberto pelo botão flutuante do Jarvis — evita duplicar no rodapé apertado */
  .nav-item[data-tab="assistant"] { display: none; }
  .nav-item {
    flex: 1; flex-direction: column; gap: 3px;
    padding: 7px 2px; border-radius: 10px;
    font-size: 9.5px; line-height: 1.15; font-weight: 600;
    text-align: center; white-space: normal;
  }
  .nav-ico { display: block; width: auto; font-size: 1.2rem; }

  main { padding: 20px 16px calc(84px + env(safe-area-inset-bottom)); }

  .grid2, .plan-fields { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat { padding: 12px; }
  .stat .num { font-size: 1.2rem; }
  .msg { max-width: 92%; }
  .chat-shell { height: calc(100dvh - 230px); }

  .view-head { align-items: flex-start; }
  .view-head .btn { width: 100%; }
  /* dois botões no cabeçalho: em 330px de largura eles não cabem lado a lado sem quebrar o rótulo */
  .head-actions { width: 100%; flex-direction: column; }
  .view-head.sub-head { margin: 26px 0 14px; padding-top: 18px; }

  .row { flex-direction: column; align-items: stretch; }
  .row .btn { width: 100%; }
  .image-choice-row { flex-direction: column; }

  /* no celular o SVG fica com ~330px de largura real: rótulo de eixo em 11px vira borrão,
     e duas colunas de gráfico não cabem sem espremer a série a ponto de mentir a forma */
  .chart-grid { grid-template-columns: 1fr; }
  .chart-card { padding: 14px 14px 8px; }
  /* "das 09:00 às 18:00 [Salvar]" não cabe numa linha de 330px sem espremer o campo de hora */
  .atd-horas { flex-direction: column; align-items: stretch; }
  .atd-horas .btn { width: 100%; }
  .chart .ax { font-size: 15px; }
  .rank .meter-legend span { max-width: 60%; }

  .gallery-grid-lg { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); }

  .btn { min-height: 44px; }
  .btn.small { min-height: 38px; }

  /* modal vira painel deslizando de baixo (bottom sheet) */
  .modal { align-items: flex-end; padding: 0; }
  .modal-box {
    max-width: 100%; max-height: 88dvh;
    border-radius: 18px 18px 0 0;
    padding-bottom: env(safe-area-inset-bottom);
    animation: sheet-up 260ms cubic-bezier(0.4, 0, 0.2, 1) both;
  }
}

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
