:root {
  --bg: #f3f1eb;
  --panel: #fffcf7;
  --ink: #1c1a16;
  --muted: #6b6560;
  --accent: #0b6e4f;
  --line: #ddd6cb;
  --danger: #b33a3a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left, #e7efe8 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
}

.top {
  padding: 1.5rem 2rem 0.5rem;
}
.top h1 {
  margin: 0;
  font-family: "IBM Plex Serif", Georgia, serif;
  font-weight: 600;
  font-size: 1.75rem;
}
.sub { margin: 0.35rem 0 0; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 1.25rem;
  padding: 1rem 2rem 2rem;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.1rem 1.25rem;
}

form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  margin-bottom: 0.65rem;
  color: var(--muted);
}
form label.check {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
form label.check input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
}
form h2 {
  margin: 1rem 0 0.6rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
}
form h2:first-child { margin-top: 0; }

input, select, button {
  font: inherit;
  padding: 0.45rem 0.55rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

button {
  width: 100%;
  margin-top: 0.75rem;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}
button:disabled { opacity: 0.6; cursor: wait; }

.status { font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.status.err { color: var(--danger); }

.aviso-ir {
  margin: 0 0 0.85rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--ink);
  background: #fff8e8;
  border: 1px solid #e6d4a8;
  border-radius: 8px;
}
.aviso-ir[hidden] {
  display: none !important;
}

.resumo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.resumo .card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
}
.resumo .k { font-size: 0.72rem; color: var(--muted); text-transform: uppercase; }
.resumo .v { font-size: 1rem; font-weight: 600; margin-top: 0.15rem; }

/* .info / .interpretar: ver bloco abaixo (após hints) */

label .hint {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
  margin-top: 0.15rem;
}

.label-row {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.label-with-info {
  position: relative;
}
.label-with-info.check {
  flex-wrap: wrap;
}
.label-with-info.check .info-tip {
  flex-basis: 100%;
  order: 3;
}
button.info {
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  margin: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  cursor: help;
  flex-shrink: 0;
}
button.info:hover,
button.info[aria-expanded="true"] {
  border-color: var(--accent);
  color: var(--accent);
}
.info-tip {
  display: block;
  margin-top: 0.35rem;
  padding: 0.55rem 0.65rem;
  font-size: 0.75rem;
  line-height: 1.45;
  color: var(--ink);
  background: #f3faf6;
  border: 1px solid rgba(11, 110, 79, 0.25);
  border-radius: 6px;
}
.info-tip[hidden] {
  display: none !important;
}

.interpretar {
  margin: 0 0 1rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.75rem 0.7rem;
}
.interpretar summary {
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
}
.interpretar summary::-webkit-details-marker { display: none; }
.interpretar summary::before {
  content: "▸ ";
  color: var(--accent);
}
.interpretar[open] summary::before { content: "▾ "; }
.interpretar-body {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink);
}
.interpretar-destaque {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.6rem;
  background: #f3faf6;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.interpretar-body ol {
  margin: 0;
  padding-left: 1.15rem;
}
.interpretar-body li {
  margin-bottom: 0.65rem;
}
.interpretar-body li:last-child { margin-bottom: 0; }
.interpretar-ref {
  margin: 0.75rem 0 0;
  font-size: 0.72rem;
  color: var(--muted);
}
.interpretar-ref code {
  font-size: 0.7rem;
}

.resumo .card {
  position: relative;
}
.resumo .k {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.resumo .card .info {
  width: 1rem;
  height: 1rem;
  font-size: 0.62rem;
}
.resumo .card .info-tip {
  position: absolute;
  z-index: 5;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  margin-top: 0;
  box-shadow: 0 6px 18px rgba(28, 26, 22, 0.12);
}

.ir-bloco {
  margin-top: 0.35rem;
  padding-top: 0.25rem;
  border-top: 1px dashed var(--line);
}
.ir-bloco h2 {
  margin-top: 0.75rem;
}

.janelas {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}
.janelas .bloco {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem 0.7rem;
  max-height: 280px;
  overflow: auto;
}
.janelas h3 {
  margin: 0 0 0.4rem;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.janelas table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.janelas th, .janelas td {
  text-align: left;
  padding: 0.22rem 0.3rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.janelas th { color: var(--muted); font-weight: 600; }
.janelas td.num { text-align: right; font-variant-numeric: tabular-nums; }
.janelas .pos { color: var(--accent); }
.janelas .neg { color: var(--danger); }

.comparacao-wrap { margin-bottom: 1.25rem; }

.carteira-wrap {
  margin-bottom: 1.25rem;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.85rem 0.9rem;
}
.carteira-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}
.carteira-head h3 {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.carteira-legenda {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--muted);
}
.carteira-mes {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0;
}
.carteira-mes-nav {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}
.carteira-mes select {
  min-width: 8rem;
}
.carteira-mes-btn {
  width: 2rem;
  height: 2rem;
  padding: 0;
  line-height: 1;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.carteira-mes-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}
.carteira-mes-btn:disabled {
  opacity: 0.35;
  cursor: default;
}
.carteira-cols {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.3fr) minmax(0, 0.85fr);
  gap: 0.65rem;
  align-items: start;
}
.carteira-col {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.45rem 0.5rem 0.55rem;
  background: var(--panel);
  opacity: 0.72;
}
.carteira-col.anchor {
  border-color: var(--accent);
  background: #f3faf6;
  opacity: 1;
  box-shadow: 0 0 0 1px rgba(11, 110, 79, 0.15);
}
.carteira-col h4 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  font-weight: 600;
}
.carteira-col ol {
  margin: 0;
  padding: 0;
  list-style: none;
}
.carteira-col li {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  font-size: 0.8rem;
  padding: 0.18rem 0.2rem;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.carteira-col li .tk { font-weight: 600; }
.carteira-col li .meta { color: var(--muted); font-size: 0.72rem; }
.carteira-col li.in { background: rgba(11, 110, 79, 0.12); }
.carteira-col li.out { background: rgba(179, 58, 58, 0.1); color: var(--danger); }
.carteira-col .empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 1rem; }
  .carteira-cols { grid-template-columns: 1fr; }
}
