/* ==========================================================================
   Paleta oficial — "Basic Guidelines for Santander" (2020), pág. 12.
   Regra do guia: SOMENTE as cores marcadas com * podem ser usadas como fundo:
   White*, Lisbon*, Rio* e Santander Red*. As demais são usadas apenas em
   detalhes (bordas, estados, textos). Sem logotipo: uso da marca exige licença.
   ========================================================================== */
:root {
  color-scheme: light;

  /* Primárias */
  --santander-red: #ec0000; /* * fundo permitido */
  --white: #ffffff;         /* * fundo permitido */
  --black: #000000;
  /* Tons suaves */
  --lisbon: #fbf1ea;        /* * fundo permitido */
  --rio: #f5decf;           /* * fundo permitido */
  --mexico-city: #f0b998;
  --madrid: #ea6f5d;
  /* Tons escuros */
  --boston: #cc0000;
  --london: #990000;

  /* Tokens semânticos */
  --bg: var(--lisbon);
  --surface: var(--white);
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --border: var(--rio);
  --accent: var(--santander-red);
  --accent-hover: var(--boston);
  --accent-active: var(--london);
  --link: var(--boston);  /* contraste AA sobre branco */
  --ok: #1e7a3c;          /* verde funcional para entradas/sucesso (fora da marca, só em texto) */
  --bad: var(--boston);
}

* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--link); }
a:hover { color: var(--london); }

button { font: inherit; cursor: pointer; border: 1px solid transparent; border-radius: 8px; padding: 8px 14px; background: var(--accent); color: var(--white); font-weight: 600; transition: background .15s, color .15s, border-color .15s; }
button:hover { background: var(--accent-hover); }
button:active { background: var(--accent-active); }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid var(--london); outline-offset: 2px; }
button.ghost { background: var(--white); color: var(--boston); border-color: var(--boston); }
button.ghost:hover { background: var(--lisbon); color: var(--london); border-color: var(--london); }
button:disabled { opacity: .5; cursor: wait; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; border-radius: 8px; padding: 8px 14px; font-weight: 600; border: 1px solid transparent; }
.topbar a.btn.ghost { color: var(--white); border-color: rgba(255, 255, 255, .8); }
.topbar a.btn.ghost:hover { background: var(--white); color: var(--santander-red); }
.saved-note { font-size: 12px; color: var(--muted); padding: 0 12px 10px; }
.guard-note { margin-top: 6px; font-size: 12px; color: var(--london); }

/* Topbar em Santander Red (fundo permitido) */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 20px; background: var(--santander-red); color: var(--white); }
.brand { font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 17px; }
.brand small { font-weight: 400; opacity: .9; font-size: 14px; }
.logo { background: var(--white); color: var(--santander-red); border-radius: 6px; padding: 3px 8px; font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; border: 1px solid rgba(255, 255, 255, .75); border-radius: 999px; padding: 1px 8px; }
.topbar button.ghost { background: transparent; color: var(--white); border-color: rgba(255, 255, 255, .8); }
.topbar button.ghost:hover { background: var(--white); color: var(--santander-red); border-color: var(--white); }

.layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; padding: 16px; height: calc(100vh - 60px - 34px); }

/* Chat */
.chat { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; min-height: 0; }
.messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 12px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--santander-red); color: var(--white); border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--lisbon); border: 1px solid var(--rio); border-bottom-left-radius: 4px; }
.msg.typing { color: var(--muted); font-style: italic; }
.tools { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tool { font: 12px ui-monospace, Menlo, monospace; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--rio); background: var(--white); }
.tool.ok { color: var(--ok); } .tool.err { color: var(--bad); }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); }
.composer input { flex: 1; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--mexico-city); background: var(--white); color: var(--text); font: inherit; }

/* Lateral */
.side { display: flex; flex-direction: column; gap: 12px; overflow-y: auto; min-height: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.label.sub { margin-top: 12px; }
.balance { border-top: 4px solid var(--santander-red); }
.amount { font-size: 30px; font-weight: 700; color: var(--santander-red); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .tiny { font-size: 12px; margin-top: 6px; }
.pending { background: var(--rio); border-color: var(--mexico-city); }
.pending .label { color: var(--london); }
.row { display: flex; gap: 8px; margin-top: 10px; }
.row.tight { margin-top: 0; }
.hidden { display: none; }
.statement { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.statement li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; font-variant-numeric: tabular-nums; }
.statement .in { color: var(--ok); } .statement .out { color: var(--london); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { background: var(--white); color: var(--text); border: 1px solid var(--mexico-city); font-size: 13px; font-weight: 400; padding: 4px 10px; text-align: left; }
.chips button:hover { background: var(--lisbon); border-color: var(--santander-red); }
.chips.bad button { border-style: dashed; border-color: var(--madrid); }

.footer { height: 34px; display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }

/* Diálogo "Sobre o projeto" */
dialog#about { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 0; border-top: 4px solid var(--santander-red); border-radius: 14px; padding: 20px; background: var(--white); color: var(--text); }
dialog#about::backdrop { background: rgba(0, 0, 0, .45); }
.about-head { display: flex; justify-content: space-between; align-items: center; }
.about-head h2 { margin: 0; font-size: 20px; color: var(--santander-red); }
.about-cta { margin-top: 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--rio); border: 1px solid var(--mexico-city); border-left: 6px solid var(--santander-red); border-radius: 12px; padding: 14px 16px; }
.cta-title { font-weight: 700; font-size: 16px; color: var(--london); }
.about-cta .tiny { margin-top: 2px; }
a.btn.primary { background: var(--santander-red); color: var(--white); }
a.btn.primary:hover { background: var(--boston); color: var(--white); }
a.btn.outline { background: var(--white); color: var(--boston); border-color: var(--boston); }
a.btn.outline:hover { background: var(--lisbon); color: var(--london); }
dialog#about section { margin-top: 16px; }
dialog#about h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
dialog#about p { margin: 0; }
#ab-nome { font-size: 16px; text-transform: none; letter-spacing: 0; color: var(--text); }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
code { font: 13px ui-monospace, Menlo, monospace; background: var(--lisbon); border: 1px solid var(--rio); border-radius: 4px; padding: 1px 5px; }
.links { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.links a { word-break: break-word; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; height: auto; padding: 16px; }
  .chat { height: 70vh; }
  .msg { max-width: 92%; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .brand small { display: none; }
  .kv, .links { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .footer { height: auto; padding: 8px 16px 16px; }
}
