/* ===================================================
   CARTEIRA DE INVESTIMENTOS — STYLESHEET
   =================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:              #f0f4f8;
  --card-bg:         #ffffff;
  --border:          #e2e8f0;
  --text-primary:    #1e293b;
  --text-secondary:  #64748b;
  --text-muted:      #94a3b8;

  --buy-bg:   #dcfce7; --buy-txt:   #15803d; --buy-border: #86efac;
  --sell-bg:  #fee2e2; --sell-txt:  #b91c1c; --sell-border:#fca5a5;
  --hold-bg:  #fef9c3; --hold-txt:  #a16207; --hold-border:#fde047;

  --green:    #22c55e; --green-dk:  #16a34a;
  --red:      #ef4444; --red-dk:    #dc2626;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.09);
  --radius:    12px;
  --trans:     0.18s ease;
}

html { font-size: 14px; }

/* ===== MODO ESCURO ===== */
body.dark {
  --bg:             #0f172a;
  --card-bg:        #1e293b;
  --border:         #334155;
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  --buy-bg:    #14532d; --buy-txt:   #86efac; --buy-border: #166534;
  --sell-bg:   #7f1d1d; --sell-txt:  #fca5a5; --sell-border:#991b1b;
  --hold-bg:   #713f12; --hold-txt:  #fde047; --hold-border:#92400e;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3),  0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
}
body.dark .top-header       { background: #1e293b; border-bottom: 1px solid #334155; }
body.dark .tab-nav          { background: #1e293b; border-bottom: 1px solid #334155; }
body.dark .tab-btn          { color: #94a3b8; }
body.dark .tab-btn.active   { color: #f1f5f9; border-bottom-color: #7c3aed; }
body.dark .benchmarks-bar   { background: #1e293b; border-bottom: 1px solid #334155; }
body.dark .portfolio-summary-bar { background: #1e293b; border-bottom: 1px solid #334155; }
body.dark .history-panel    { background: #1e293b; border-top: 1px solid #334155; }
body.dark .modal-box        { background: #1e293b; }
body.dark input, body.dark select, body.dark textarea { background: #0f172a; color: #f1f5f9; border-color: #334155; }
body.dark .search-input     { background: #0f172a; color: #f1f5f9; }
body.dark .alloc-bar-track  { background: #334155; }
body.dark .bench-period-btn { border-color: #334155; color: #94a3b8; }
body.dark .bench-period-btn:hover { background: #334155; }

/* Sugestões — dark mode overrides residuais */
body.dark .sug-type-badge.watch { background: #2d2f6e; color: #a5b4fc; }
body.dark .suggestions-count    { background: #7c3aed; }
body.dark .btn-sug-execute      { background: #7c3aed; }
body.dark .btn-sug-execute:hover { background: #6d28d9; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .2s, color .2s;
}

/* ===== CONTENT WRAPPER ===== */
.content-wrapper {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ===== TOP HEADER ===== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  /* Permite que o bloco da direita desca para a proxima linha quando nao couber,
     em vez de empurrar a pagina para fora. Ver o comentario em .header-right. */
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.page-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  /* `flex-shrink: 0` fazia este bloco (848px de botoes) se recusar a encolher e
     VAZAR do cabecalho: medido em 24/09/2026, a pagina ganhava 14px de rolagem
     horizontal a 1024px de largura. Abaixo de 768px ja havia media query
     empilhando tudo; a faixa entre 768px e ~1100px ficava sem tratamento.
     Agora o bloco pode quebrar para a linha de baixo em vez de vazar — os
     botoes continuam sem encolher (flex-shrink nos filhos), so mudam de linha. */
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}
.header-right > * { flex-shrink: 0; }
.last-update-text {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans);
}
.btn-refresh:hover { background: #4f46e5; }
.btn-refresh:active { transform: scale(0.97); }
.btn-refresh.loading .refresh-icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.btn-dark-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 15px;
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
  line-height: 1;
}
.btn-dark-toggle:hover { background: var(--border); color: var(--text-primary); }

/* ===== PORTFOLIO SUMMARY BAR ===== */
.portfolio-summary-bar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 0;
  flex-wrap: wrap;
}

.summary-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 24px 0 0;
}
.summary-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  white-space: nowrap;
}
.summary-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}
.summary-value.positive { color: #16a34a; }
.summary-value.negative { color: #dc2626; }

.summary-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  margin: 0 24px 0 0;
  flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
#mainContent {
  padding: 24px 28px;
  flex: 1;
}

/* ===== LOADING ===== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-secondary);
  gap: 16px;
}
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ===== SECTION ===== */
.section { margin-bottom: 36px; }

.section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.section-accent {
  width: 4px;
  height: 22px;
  border-radius: 4px;
  flex-shrink: 0;
}
.section-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== ASSETS GRID ===== */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

@media (max-width: 1400px) { .assets-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1050px) { .assets-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .assets-grid { grid-template-columns: 1fr; } }

/* ===== ASSET CARD ===== */
.asset-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--trans), transform var(--trans);
  position: relative;
  overflow: hidden;
}
.asset-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.card-ticker {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 5px;
}
.card-country-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  color: #475569;
}
.card-name {
  font-size: 11.5px;
  color: var(--text-secondary);
}
/* Dados alternativos no card (insider, put/call, próximo evento) */
.card-altdata {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 6px 0 2px;
}
.alt-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap;
}
.alt-badge b { font-weight: 800; }
.alt-badge.alt-buy   { background: #dcfce7; color: #166534; }
.alt-badge.alt-sell  { background: #fee2e2; color: #991b1b; }
.alt-badge.alt-event { background: #e0e7ff; color: #3730a3; }
.alt-badge.alt-neutral { background: #f1f5f9; color: #475569; }
body.dark .alt-badge         { background: #334155; color: #cbd5e1; }
body.dark .alt-badge.alt-buy   { background: #14532d; color: #bbf7d0; }
body.dark .alt-badge.alt-sell  { background: #7f1d1d; color: #fecaca; }
body.dark .alt-badge.alt-event { background: #312e81; color: #c7d2fe; }
body.dark .alt-badge.alt-neutral { background: #334155; color: #cbd5e1; }

/* Signal badge */
.signal-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
  flex-shrink: 0;
}
.signal-buy   { background: var(--buy-bg);  color: var(--buy-txt);  border-color: var(--buy-border); }
.signal-sell  { background: var(--sell-bg); color: var(--sell-txt); border-color: var(--sell-border);}
.signal-hold  { background: var(--hold-bg); color: var(--hold-txt); border-color: var(--hold-border);}

.signal-target {
  font-size: 10.5px;
  color: var(--buy-txt);
  font-weight: 600;
}
.signal-target.sell-target { color: var(--sell-txt); }

/* Sparkline */
.sparkline-wrap {
  width: 100%;
  height: 52px;
  cursor: pointer;
  border-radius: 6px;
  overflow: hidden;
  background: #fafafa;
  transition: opacity var(--trans);
  position: relative;
}
.sparkline-wrap:hover { opacity: 0.85; }
.sparkline-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}
.sparkline-wrap .no-data {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
}
/* Overlay de variação % e período no mini-gráfico */
.spark-var {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.88);
  line-height: 1.4;
  pointer-events: none;
}
.spark-var.positive { color: #16a34a; }
.spark-var.negative { color: #dc2626; }
.spark-period {
  position: absolute;
  bottom: 4px;
  left: 5px;
  font-size: 9px;
  color: #94a3b8;
  background: rgba(255,255,255,0.75);
  padding: 0 3px;
  border-radius: 3px;
  pointer-events: none;
}

/* Price info grid */
.price-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 8px;
}
.price-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.price-row-label {
  font-size: 10.5px;
  color: var(--text-muted);
}
.price-row-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.price-row-value.positive { color: #16a34a; }
.price-row-value.negative { color: #dc2626; }
.price-row-value.muted    { color: #94a3b8; }

/* Allocation bar */
.alloc-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 2px;
}
.alloc-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
}
.alloc-values {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
}
.alloc-bar-track {
  height: 4px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.alloc-bar-suggested {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  background: #cbd5e1;
  border-radius: 4px;
}
.alloc-bar-actual {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* Card actions */
.card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
}
.qty-input {
  width: 72px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-primary);
  background: #f8fafc;
  outline: none;
  transition: border-color var(--trans);
  -moz-appearance: textfield;
}
.qty-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.qty-input:focus { border-color: #6366f1; background: #fff; }

.btn-buy, .btn-sell {
  flex: 1;
  padding: 7px 6px;
  border: none;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.btn-buy  { background: var(--green); color: #fff; }
.btn-buy:hover  { background: var(--green-dk); }
.btn-sell { background: var(--red); color: #fff; }
.btn-sell:hover { background: var(--red-dk); }
.btn-buy:active, .btn-sell:active { transform: scale(0.96); }

/* ===== HISTORY PANEL ===== */
.history-panel {
  margin: 0 28px 28px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.history-header h3 { font-size: 14px; font-weight: 700; }
.history-actions { display: flex; gap: 8px; }

.btn-secondary {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans);
}
.btn-secondary:hover { background: #f1f5f9; }

.history-table-wrapper { overflow-x: auto; max-height: 320px; overflow-y: auto; }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.history-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 10.5px;
  letter-spacing: 0.04em;
}
.history-table td {
  padding: 8px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: #fafafa; }
.history-table .type-buy  { color: #16a34a; font-weight: 700; }
.history-table .type-sell { color: #dc2626; font-weight: 700; }
.history-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

/* ===== FAB BUTTON ===== */
.fab-history {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 50px; height: 50px;
  border-radius: 50%;
  background: #1a1f2e;
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 90;
  transition: background var(--trans), transform var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
}
.fab-history:hover { background: #2d3448; transform: scale(1.06); }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 90px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 11px 18px;
  border-radius: 10px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: slideIn 0.25s ease;
  max-width: 320px;
}
.toast-success  { background: #16a34a; }
.toast-error    { background: #dc2626; }
.toast-info     { background: #6366f1; }
.toast-warning  { background: #b45309; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: 460px;
  max-width: 94vw;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}
.modal-close {
  position: absolute;
  top: 14px; right: 14px;
  width: 28px; height: 28px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
}
.modal-close:hover { background: #e2e8f0; }
#modalTitle {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 14px;
}
#modalBody {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}
#modalBody strong { color: var(--text-primary); }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn-cancel {
  padding: 9px 18px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.btn-cancel:hover { background: #f1f5f9; }
.btn-confirm {
  padding: 9px 22px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: #22c55e;
  transition: background var(--trans);
}
.btn-confirm:hover { background: #16a34a; }
.btn-confirm.sell-confirm { background: #ef4444; }
.btn-confirm.sell-confirm:hover { background: #dc2626; }

/* chart popup sparkline bigger */
.chart-popup-svg {
  width: 100%;
  height: 150px;
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
  display: block;
}
.chart-popup-svg svg { width: 100%; height: 100%; display: block; }

/* ===== AGENT STATUS BADGE ===== */
.agent-status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: background var(--trans), border-color var(--trans);
}
.agent-status-badge.online  { background: #f0fdf4; border-color: #bbf7d0; }
.agent-status-badge.offline { background: #f8fafc; border-color: var(--border); }
.agent-status-badge.busy    { background: #fffbeb; border-color: #fde68a; }

.agent-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
}
.agent-dot.online  { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.25); animation: pulse-dot 2s ease infinite; }
.agent-dot.offline { background: #cbd5e1; }
.agent-dot.busy    { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245,158,11,0.25); }
@keyframes pulse-dot {
  0%,100% { box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }
  50%     { box-shadow: 0 0 0 5px rgba(34,197,94,0.10); }
}

.header-sep {
  width: 1px; height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

/* ===== TOOLBAR ===== */
.toolbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 10px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.toolbar-left  { display: flex; align-items: center; gap: 12px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }

.search-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color var(--trans), box-shadow var(--trans);
}
.search-wrap:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
}
.search-icon {
  padding: 0 8px 0 10px;
  font-size: 13px;
  line-height: 1;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  border: none;
  background: transparent;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--text-primary);
  width: 220px;
  outline: none;
}
.search-input::placeholder { color: var(--text-muted); }
.search-clear {
  border: none;
  background: transparent;
  padding: 0 10px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  display: none;
  line-height: 36px;
}
.search-clear:hover { color: var(--text-primary); }
.search-clear.visible { display: block; }

.search-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sort-label { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.sort-select {
  padding: 7px 28px 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  font-size: 12.5px;
  color: var(--text-primary);
  cursor: pointer;
  outline: none;
  transition: border-color var(--trans);
}
.sort-select:focus { border-color: #6366f1; }

/* ===== SUGGESTIONS PANEL ===== */
.suggestions-section {
  margin: 16px 28px 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.suggestions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.suggestions-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.suggestions-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: #6366f1;
  color: #fff;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
}
.suggestions-actions { display: flex; gap: 8px; }
.btn-sug-dismiss {
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: #6366f1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans);
}
.btn-sug-dismiss:hover { background: var(--bg); }

/* Barra de sugestões expiradas */
.sug-expired-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; margin: 0 0 10px;
  background: var(--hold-bg); border: 1px solid var(--hold-border); border-radius: 8px;
  font-size: 12px; color: var(--hold-txt);
}
.btn-sug-reject-expired {
  margin-left: auto; padding: 3px 10px;
  border: 1px solid var(--hold-border); border-radius: 5px;
  background: var(--hold-bg); color: var(--hold-txt);
  font-size: 11px; font-weight: 600; cursor: pointer;
}
.btn-sug-reject-expired:hover { opacity: 0.8; }

/* Log do Agente (_RESUMO) */
/* O log fica DENTRO da .suggestions-section, que nao tem padding proprio: quem
   afasta os cards das bordas e o padding da .suggestions-grid (14px 18px). Sem
   margem lateral, o log saia 18px mais largo que os cards de cima e com a borda
   colada na borda da secao (linha dobrada), e sem margem inferior ele encostava
   no rodape arredondado. Medido em 12/09/2026: cards 47..349, log 29..995,
   secao 28..996. */
.sug-log-agente {
  margin: 14px 18px 18px; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden;
}
/* Estado vazio: com zero sugestoes acionaveis a .suggestions-grid ainda pintava
   uma faixa de 28px (so o proprio padding) entre a barra de selecao e o log. */
.sug-vazio {
  padding: 18px; text-align: center;
  font-size: 13px; color: var(--text-muted);
}
.sug-log-agente summary {
  padding: 10px 14px; background: var(--bg);
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  cursor: pointer; user-select: none;
  list-style: none;
}
.sug-log-agente summary::-webkit-details-marker { display: none; }
.sug-log-agente[open] summary { border-bottom: 1px solid var(--border); }
.sug-log-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 12px; }
.sug-log-entry { position: relative; }
.sug-log-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.sug-log-text {
  font-size: 12px; color: var(--text-secondary); line-height: 1.5;
  white-space: pre-wrap;
}
.btn-sug-reject-sm {
  margin-top: 6px; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg); color: var(--text-muted);
  font-size: 11px; cursor: pointer;
}
.btn-sug-reject-sm:hover { background: var(--sell-bg); color: var(--sell-txt); border-color: var(--sell-border); }

.suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 14px 18px;
}

.suggestion-card {
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--card-bg);
  transition: box-shadow var(--trans);
}
.suggestion-card:hover { box-shadow: var(--shadow-sm); }
.suggestion-card.type-buy   { border-left: 3px solid #22c55e; }
.suggestion-card.type-sell  { border-left: 3px solid #ef4444; }
.suggestion-card.type-watch { border-left: 3px solid #6366f1; }

.sug-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sug-ticker { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.sug-name   { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.sug-type-badge {
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.sug-type-badge.buy   { background: var(--buy-bg);  color: var(--buy-txt); }
.sug-type-badge.sell  { background: var(--sell-bg); color: var(--sell-txt); }
.sug-type-badge.watch { background: #eef2ff; color: #4338ca; }

.sug-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  font-size: 12px;
}
.sug-detail-label { color: var(--text-muted); }
.sug-detail-value { font-weight: 600; color: var(--text-primary); }

.sug-reason {
  font-size: 11.5px;
  color: var(--text-primary);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  line-height: 1.6;
}

/* APROVAÇÃO AGENDADA: o cartão continua na fila, mas já tem a decisão dele.
   Tarja âmbar para não parecer um cartão intocado — era o que fazia aprovar duas
   vezes. */
.sug-armed {
  font-size: 11.5px;
  font-weight: 600;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 6px;
  padding: 7px 10px;
  line-height: 1.5;
}

.sug-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
}

.sug-card-actions {
  display: flex;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}
.btn-sug-approve, .btn-sug-reject, .btn-sug-execute {
  flex: 1;
  padding: 7px 6px;
  border: none;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--trans), transform var(--trans);
}
.btn-sug-approve { background: var(--buy-bg);  color: var(--buy-txt); }
.btn-sug-approve:hover { opacity: 0.85; }
.btn-sug-reject  { background: var(--sell-bg); color: var(--sell-txt); }
.btn-sug-reject:hover  { opacity: 0.85; }
.btn-sug-execute { background: #6366f1; color: #fff; }
.btn-sug-execute:hover { background: #4f46e5; }
.btn-sug-approve:active, .btn-sug-reject:active, .btn-sug-execute:active { transform: scale(0.96); }

/* Hidden cards (filter) */
.asset-card.card-hidden { display: none !important; }

/* ===== COLLECT BUTTON ===== */
.btn-collect {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: #0f766e;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--trans), transform var(--trans);
}
.btn-collect:hover:not(:disabled) { opacity: .88; transform: translateY(-1px); }
.btn-collect:disabled { opacity: .55; cursor: default; }

/* ===== ANALYSIS BUTTON ===== */
.btn-analysis {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--trans), transform var(--trans), background var(--trans);
  white-space: nowrap;
}
.btn-analysis:hover:not(:disabled) { opacity: 0.88; transform: translateY(-1px); }
.btn-analysis:active { transform: scale(0.97); }
.btn-analysis:disabled { cursor: default; }
.btn-analysis.requested {
  background: linear-gradient(135deg, #d97706, #f59e0b);
  animation: pulse-analysis 1.8s ease infinite;
}
@keyframes pulse-analysis {
  0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,0.4); }
  50%      { box-shadow: 0 0 0 6px rgba(245,158,11,0); }
}

/* subtitle */
.page-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.subtitle-sep  { color: var(--text-muted); }

/* ===== TAB NAVIGATION ===== */
.tab-nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}
.tab-btn {
  position: relative;
  padding: 12px 20px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color var(--trans), border-color var(--trans);
  display: flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}
.tab-btn:hover  { color: var(--text-primary); background: #f8fafc; }
.tab-btn.active { color: #6366f1; border-bottom-color: #6366f1; }
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #6366f1;
  color: #fff;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
}

/* ===== TAB CONTENT ===== */
.tab-content        { display: none; }
.tab-content.active { display: block; }

/* ===== WATCHLIST ===== */
.watchlist-add-bar {
  margin: 16px 28px 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.wl-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-wl-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: #6366f1;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background var(--trans), opacity var(--trans);
}
.btn-wl-search:hover:not(:disabled) { background: #4f46e5; }
.btn-wl-search:disabled { opacity: 0.6; cursor: default; }

/* Lista de resultados da busca */
.wl-search-results {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.wl-search-results-header {
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}
.wl-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background var(--trans);
}
.wl-result-item:last-child { border-bottom: none; }
.wl-result-item:hover { background: #f0f4ff; }
.wl-result-ticker {
  font-size: 14px;
  font-weight: 800;
  color: #1e293b;
  min-width: 72px;
}
.wl-result-name {
  flex: 1;
  font-size: 13px;
  color: #475569;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wl-result-exchange {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  background: #f1f5f9;
  padding: 2px 7px;
  border-radius: 12px;
}
.wl-result-type-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.wl-result-type-badge.br  { background: #dbeafe; color: #1d4ed8; }
.wl-result-type-badge.us  { background: #dcfce7; color: #15803d; }
.wl-result-type-badge.cr  { background: #fef3c7; color: #92400e; }
.wl-result-type-badge.fx  { background: #f3e8ff; color: #7c3aed; }
.wl-result-type-badge.etc { background: #f1f5f9; color: #64748b; }

/* Preview de resultado da pesquisa */
.wl-preview-error {
  padding: 12px 16px;
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  font-size: 13px;
  color: #dc2626;
}
.wl-preview-card {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 14px 16px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  flex-wrap: wrap;
}
.wl-preview-info { flex: 1; min-width: 200px; }
.wl-preview-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.wl-preview-price { font-size: 22px; font-weight: 700; margin-top: 8px; }
.wl-preview-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}
.wl-notes-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
  outline: none;
  transition: border-color var(--trans);
}
.wl-notes-input:focus { border-color: #6366f1; }
.wl-preview-btns { display: flex; gap: 8px; }
.btn-wl-add {
  flex: 1;
  padding: 9px 14px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--trans);
}
.btn-wl-add:hover { background: #15803d; }

.watchlist-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 16px 28px 24px;
}
@media (max-width: 1400px) { .watchlist-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1050px) { .watchlist-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .watchlist-grid { grid-template-columns: 1fr; } }

.watchlist-empty {
  grid-column: 1/-1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.wl-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-top: 3px solid #6366f1;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--trans), transform var(--trans);
}
.wl-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.wl-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.wl-ticker { font-size: 16px; font-weight: 700; }
.wl-name   { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.wl-notes  { font-size: 11px; color: var(--text-muted); font-style: italic; }

.btn-wl-remove {
  border: none;
  background: #f1f5f9;
  color: var(--text-muted);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--trans), color var(--trans);
}
.btn-wl-remove:hover { background: #fee2e2; color: #dc2626; }

.wl-price-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.wl-price     { font-size: 18px; font-weight: 700; }
.wl-var       { font-size: 12px; font-weight: 700; }
.wl-var.positive { color: #16a34a; }
.wl-var.negative { color: #dc2626; }

.wl-card-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid #f1f5f9;
}

/* ===== BATCH SUGGESTION CARD ===== */
.batch-card { border-left: 3px solid #6366f1; }
.batch-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #6366f1;
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  margin-left: 4px;
}
.batch-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.batch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #f8fafc;
  border-radius: 7px;
  cursor: pointer;
  transition: background var(--trans);
  flex-wrap: wrap;
}
.batch-row:hover { background: #f1f5f9; }
.batch-row input[type=checkbox] {
  width: 15px; height: 15px;
  accent-color: #6366f1;
  cursor: pointer;
  flex-shrink: 0;
}
.batch-ticker  { font-weight: 700; font-size: 13px; min-width: 52px; }
.batch-detail  { font-size: 11.5px; color: var(--text-secondary); flex: 1; }
.batch-price   { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ===== APORTE BUTTON ===== */
.btn-aporte {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--trans);
}
.btn-aporte:hover { background: #15803d; }

/* ===== URGENT SUGGESTION ===== */
/* Urgência NÃO sobrescreve a cor semântica do TIPO (compra=verde, venda=vermelho,
   monitorar=índigo na borda): sinaliza com fundo âmbar de alerta + badge 🚨 pulsante.
   Antes: fundo vermelho de venda em qualquer tipo — "monitorar" parecia venda urgente. */
.suggestion-card.urgent {
  background: var(--hold-bg);
}
.sug-priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  background: #ef4444;
  color: #fff;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  animation: pulse-urgent 1.5s ease infinite;
}
@keyframes pulse-urgent {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.7; }
}

/* ===== SUGGESTION MASTER CHECKBOX ===== */
.sug-master-check {
  width: 15px; height: 15px;
  accent-color: #6366f1;
  cursor: pointer;
  flex-shrink: 0;
}
.sug-select-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.sug-select-info { font-size: 12px; color: var(--text-secondary); flex: 1; }
.btn-sug-sel-approve, .btn-sug-sel-reject {
  padding: 5px 12px;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity var(--trans);
}
.btn-sug-sel-approve { background: var(--buy-bg);  color: var(--buy-txt); }
.btn-sug-sel-approve:hover { opacity: 0.85; }
.btn-sug-sel-reject  { background: var(--sell-bg); color: var(--sell-txt); }
.btn-sug-sel-reject:hover  { opacity: 0.85; }

/* ===== DIVIDEND MARKER IN CHART ===== */
.chart-div-tip {
  position: absolute;
  background: rgba(109,40,217,0.92);
  color: #fff;
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
  top: 4px;
}

/* ===== APORTE MODAL FORM ===== */
.aporte-form { display: flex; flex-direction: column; gap: 14px; }
.aporte-form label { font-size: 12px; color: var(--text-secondary); font-weight: 600; display: block; margin-bottom: 4px; }
.aporte-form input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none;
  transition: border-color var(--trans);
}
.aporte-form input:focus { border-color: #6366f1; }
.aporte-tabs { display: flex; gap: 6px; margin-bottom: 4px; }
.aporte-tab {
  flex: 1; padding: 7px;
  border: 1px solid var(--border); border-radius: 7px;
  background: #f8fafc; font-size: 12px; font-weight: 700;
  cursor: pointer; text-align: center;
  transition: background var(--trans), color var(--trans), border-color var(--trans);
}
.aporte-tab.active { background: #6366f1; color: #fff; border-color: #6366f1; }

/* ===== BENCHMARKS BAR ===== */
.benchmarks-bar {
  background: #0f172a;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 0;
  overflow-x: auto;
  height: 36px;
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}
.bench-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 0 0;
  font-size: 12px;
  color: #94a3b8;
  white-space: nowrap;
  border-right: 1px solid #1e293b;
  margin-right: 16px;
}
.bench-chip:last-child { border-right: none; margin-right: 0; }
.bench-label { color: #64748b; font-size: 11px; text-transform: uppercase; }
.bench-val   { color: #e2e8f0; font-weight: 600; }
.bench-up    { color: #22c55e; }
.bench-dn    { color: #ef4444; }
/* Sem fechamento anterior na janela: um traco honesto no lugar de +0,00%. */
.bench-na { color: var(--muted, #64748b); font-weight: 600; }

/* ===== ORPHAN CARDS ===== */
.orphan-card { border-left: 3px solid #f59e0b; }
.orphan-badge {
  display: inline-block;
  font-size: 10px;
  background: #fff7ed;
  color: #92400e;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 6px;
}

/* ===== DIVIDENDOS TAB ===== */
.div-tab-header { display:flex; justify-content:space-between; align-items:flex-start; padding:20px 28px 0; flex-wrap:wrap; gap:12px; }
.div-summary-cards { display:flex; gap:12px; flex-wrap:wrap; }
.div-summary-card { background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:14px 20px; min-width:160px; }
.div-summary-card .label { font-size:11px; color:var(--text-muted); text-transform:uppercase; font-weight:600; margin-bottom:4px; }
.div-summary-card .value { font-size:20px; font-weight:700; color:#7c3aed; }
.div-table-wrapper { padding:20px 28px; }
.div-table { width:100%; border-collapse:collapse; font-size:13px; }
.div-table th { text-align:left; padding:8px 12px; font-size:11px; text-transform:uppercase; color:var(--text-muted); border-bottom:2px solid var(--border); }
.div-table td { padding:10px 12px; border-bottom:1px solid #f1f5f9; }
.div-table tr:hover td { background:#f8fafc; }
.btn-register-div { padding:9px 18px; background:#7c3aed; color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; }
.btn-register-div:hover { background:#6d28d9; }

/* ===== HISTÓRICO TAB ===== */
.hist-summary-cards { display:flex; gap:12px; flex-wrap:wrap; padding:20px 28px 0; }
.hist-summary-card { background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:14px 20px; min-width:160px; }
.hist-summary-card .label { font-size:11px; color:var(--text-muted); text-transform:uppercase; font-weight:600; margin-bottom:4px; }
.hist-summary-card .value { font-size:20px; font-weight:700; }
.hist-table-wrapper { padding:20px 28px; overflow-x:auto; }
.hist-table { width:100%; border-collapse:collapse; font-size:13px; }
.hist-table th { text-align:left; padding:8px 12px; font-size:11px; text-transform:uppercase; color:var(--text-muted); border-bottom:2px solid var(--border); }
.hist-table td { padding:10px 12px; border-bottom:1px solid #f1f5f9; }
.hist-row-profit td { background:#f0fdf4; }
.hist-row-loss td   { background:#fff5f5; }

/* ===== F5: BENCHMARK PERIOD SELECTOR ===== */
.bench-period-selector {
  display: inline-flex;
  gap: 2px;
  margin-right: 10px;
  align-items: center;
}
.bench-period-btn {
  background: transparent;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  cursor: pointer;
  transition: all .15s;
}
.bench-period-btn:hover  { background: #f1f5f9; color: #1e293b; }
.bench-period-btn.active { background: #7c3aed; color: #fff; border-color: #7c3aed; }

/* ===== F7: NOTAS POR POSIÇÃO ===== */
/* ===== CARD NEWS PANEL ===== */
.card-news-section {
  border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px;
}
.btn-news-toggle {
  background: none; border: none; color: var(--text-muted);
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 2px 0;
  transition: color .15s; display: flex; align-items: center; gap: 4px;
}
.btn-news-toggle:hover { color: #0284c7; }
.card-news-body { margin-top: 6px; display: flex; flex-direction: column; gap: 5px; }
.news-item {
  padding: 5px 8px; border-radius: 6px; background: var(--bg);
  border-left: 3px solid var(--border);
  font-size: 11px; line-height: 1.4; color: var(--text-secondary);
}
.news-item.pos { border-left-color: #22c55e; }
.news-item.neg { border-left-color: #ef4444; }
.news-item a { color: inherit; text-decoration: none; }
.news-item a:hover { text-decoration: underline; }
.news-item-date { font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.news-sentiment-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; margin-right: 4px; vertical-align: middle;
}
.news-sentiment-dot.pos { background: #22c55e; }
.news-sentiment-dot.neg { background: #ef4444; }
.news-sentiment-dot.neutro { background: var(--text-muted); }

.card-notes-section { border-top: 1px solid var(--border); margin-top: 8px; padding-top: 6px; }
.btn-notes-toggle {
  background: none; border: none; color: #94a3b8;
  font-size: 11px; font-weight: 600; cursor: pointer; padding: 2px 0;
  transition: color .15s;
}
.btn-notes-toggle:hover { color: #7c3aed; }
.card-notes-body { margin-top: 6px; }
.notes-textarea {
  width: 100%; box-sizing: border-box;
  font-size: 12px; color: #1e293b;
  border: 1px solid #e2e8f0; border-radius: 6px;
  padding: 7px 10px; resize: vertical;
  font-family: inherit; outline: none;
  transition: border-color .15s;
}
.notes-textarea:focus { border-color: #7c3aed; }
.btn-notes-save {
  background: #7c3aed; color: #fff;
  border: none; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  padding: 4px 12px; cursor: pointer;
  transition: opacity .15s;
}
.btn-notes-save:hover { opacity: .85; }

/* ===== F8: GCAP EXPORT ===== */
.btn-gcap-export {
  display: inline-flex; align-items: center; gap: 6px;
  background: #0f172a; color: #fff;
  text-decoration: none; font-size: 12px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px;
  transition: opacity .15s;
}
.btn-gcap-export:hover { opacity: .8; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .portfolio-summary-bar { padding: 10px 12px; flex-wrap: wrap; gap: 8px; }
  .summary-item { padding-right: 10px; min-width: 80px; }
  .summary-divider { display: none; }
  #mainContent { padding: 12px; }
  .top-header { padding: 10px 12px; flex-direction: column; align-items: flex-start; gap: 8px; }
  .header-right { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
  .header-right > * { font-size: 12px !important; padding: 6px 10px !important; }
  .page-title { font-size: 17px; }
  .page-subtitle { font-size: 11px; }
  .tab-nav { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tab-btn { white-space: nowrap; font-size: 12px; padding: 8px 12px; }
  .benchmarks-bar { padding: 6px 12px; font-size: 11px; overflow-x: auto; flex-wrap: nowrap; }
  .bench-chip { flex-shrink: 0; }
  .bench-period-selector { flex-shrink: 0; }
  .toolbar { flex-direction: column; gap: 8px; padding: 10px 12px; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .sort-select { width: 100%; }
  .asset-card { padding: 14px 12px; }
  .card-ticker { font-size: 15px; }
  .card-actions { gap: 4px; }
  .qty-input { width: 60px !important; }
  .hist-table-wrapper { overflow-x: auto; }
  .hist-table { font-size: 11px; }
  .hist-summary-cards { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ===== RISK PAGE ===== */
.risco-page { padding: 20px 28px; display: flex; flex-direction: column; gap: 24px; }

.risk-cards-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.risk-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  border-left: 4px solid var(--border);
}
.risk-card.ok     { border-left-color: #22c55e; }
.risk-card.warn   { border-left-color: #f59e0b; }
.risk-card.danger { border-left-color: #ef4444; }
.risk-card-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.risk-card-value { font-size: 22px; font-weight: 800; color: var(--text-primary); margin-top: 4px; }
.risk-card-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.risk-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.risk-section-header {
  padding: 12px 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 700; color: var(--text-primary);
  display: flex; align-items: center; justify-content: space-between;
}
.risk-section-body { padding: 16px 18px; }

/* Barras de concentração de setor */
.sector-bars { display: flex; flex-direction: column; gap: 10px; }
.sector-bar-row { display: flex; align-items: center; gap: 10px; }
.sector-bar-label { width: 90px; font-size: 12px; color: var(--text-secondary); flex-shrink: 0; }
.sector-bar-track { flex: 1; height: 14px; background: var(--bg); border-radius: 7px; overflow: hidden; }
.sector-bar-fill  { height: 100%; border-radius: 7px; transition: width .5s ease; }
.sector-bar-fill.br    { background: #2563eb; }
.sector-bar-fill.us    { background: #7c3aed; }
.sector-bar-fill.crypto { background: #f59e0b; }
.sector-bar-fill.fx    { background: #0d9488; }
.sector-bar-fill.other { background: var(--text-muted); }
.sector-bar-pct   { width: 42px; text-align: right; font-size: 12px; font-weight: 700; color: var(--text-primary); }

/* Tabela de rebalanceamento */
.rebal-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.rebal-table th {
  text-align: left; padding: 6px 8px;
  font-size: 10px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
}
.rebal-table td { padding: 8px 8px; border-bottom: 1px solid var(--border); color: var(--text-primary); vertical-align: middle; }
.rebal-table tr:last-child td { border-bottom: none; }
.rebal-action { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 700; }
.rebal-action.buy  { background: var(--buy-bg);  color: var(--buy-txt); }
.rebal-action.sell { background: var(--sell-bg); color: var(--sell-txt); }
.rebal-action.hold { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* Scenarios */
.scenario-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.scenario-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px;
}
.scenario-title { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 6px; }
.scenario-value { font-size: 20px; font-weight: 800; }
.scenario-value.neg { color: #ef4444; }
.scenario-value.pos { color: #22c55e; }
.scenario-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Calendário de eventos */
.calendar-list { display: flex; flex-direction: column; gap: 8px; }
.cal-event {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
}
.cal-event.urgent { border-color: #f59e0b; background: var(--hold-bg); }
.cal-date { font-size: 11px; font-weight: 700; color: var(--text-muted); min-width: 60px; }
.cal-event.urgent .cal-date { color: var(--hold-txt); }
.cal-type-badge {
  padding: 1px 7px; border-radius: 8px;
  font-size: 10px; font-weight: 700; flex-shrink: 0;
}
.cal-type-badge.earnings { background: #dbeafe; color: #1d4ed8; }
.cal-type-badge.exdiv    { background: var(--buy-bg); color: var(--buy-txt); }
.cal-type-badge.copom    { background: var(--sell-bg); color: var(--sell-txt); }
.cal-type-badge.ibov     { background: #f3e8ff; color: #7c3aed; }
.cal-type-badge.outro    { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }
.cal-desc { font-size: 12px; color: var(--text-primary); flex: 1; }
.cal-ticker { font-size: 11px; font-weight: 700; color: var(--text-secondary); min-width: 50px; }
.btn-cal-delete { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; padding: 2px 4px; }
.btn-cal-delete:hover { color: #ef4444; }
.btn-add-event {
  padding: 5px 12px; background: var(--card-bg); color: var(--text-secondary);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: border-color var(--trans);
}
.btn-add-event:hover { border-color: #6366f1; color: #6366f1; }

/* Perfil selector */
.profile-selector {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 20px; background: var(--card-bg);
  font-size: 12px; font-weight: 600; color: var(--text-primary);
  cursor: pointer; transition: border-color var(--trans);
}
.profile-selector:hover { border-color: #6366f1; }
.profile-dot { width: 8px; height: 8px; border-radius: 50%; background: #6366f1; }

body.dark .cal-type-badge.earnings { background: #1e3a5f; color: #93c5fd; }
body.dark .cal-type-badge.ibov     { background: #3b1f6e; color: #c4b5fd; }

/* ===== TICKER TAPE (barra de índices rotativa) ===== */
.bench-tape {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  height: 100%;
}
.bench-tape-track {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  will-change: transform;
  animation: benchScroll 75s linear infinite;
}
.bench-tape-track.static { animation: none; }
.bench-tape:hover .bench-tape-track { animation-play-state: paused; }
@keyframes benchScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ===== BADGES DE ORIGEM (watchlist + fontes) ===== */
.wl-origin-badge, .src-origin-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  vertical-align: middle;
  text-transform: none;
  letter-spacing: 0;
}
.wl-origin-badge.agent, .src-origin-badge.sys {
  background: #ede9fe; color: #6d28d9;
}
.wl-origin-badge.manual, .src-origin-badge.man {
  background: #e2e8f0; color: #475569;
}
body.dark .wl-origin-badge.agent, body.dark .src-origin-badge.sys {
  background: #3b1f6e; color: #c4b5fd;
}
body.dark .wl-origin-badge.manual, body.dark .src-origin-badge.man {
  background: #334155; color: #94a3b8;
}

/* ===== RAIO-X: faixa compacta (Carteira) ===== */
.raiox-strip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 8px 14px; margin: 12px 0 4px;
}
.raiox-strip-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.raiox-strip-sep { margin-left: 10px; }
.raiox-chip {
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px;
  font-size: 12px; cursor: pointer; background: var(--bg); color: var(--text-primary);
}
.raiox-chip b { font-weight: 800; }
.raiox-chip.raiox-pos b { color: var(--buy-txt); }
.raiox-chip.raiox-neg b { color: var(--sell-txt); }
.raiox-chip:hover { border-color: var(--text-muted); }
.raiox-strip-more {
  margin-left: auto; font-size: 12px; font-weight: 600;
  color: #7c3aed; text-decoration: none; white-space: nowrap;
}
body.dark .raiox-strip-more { color: #a78bfa; }

/* ===== RÉGUA stop → preço → meta (cards) ===== */
.card-regua { margin: 8px 0 2px; }
.regua-track {
  position: relative; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #fca5a5 0%, #fde68a 30%, var(--border) 50%, #bbf7d0 100%);
}
body.dark .regua-track {
  background: linear-gradient(90deg, #7f1d1d 0%, #713f12 30%, #334155 50%, #14532d 100%);
}
.regua-avg {
  position: absolute; top: -2px; bottom: -2px; width: 1px;
  background: var(--text-muted); opacity: .7; transform: translateX(-50%);
}
.regua-dot {
  position: absolute; top: 50%; width: 11px; height: 11px; border-radius: 50%;
  background: var(--text-primary); border: 2px solid var(--card-bg);
  transform: translate(-50%, -50%); box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.regua-dot.regua-danger { background: #dc2626; }
.regua-dot.regua-goal   { background: #16a34a; }
.regua-labels {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-muted); margin-top: 3px;
}

/* ===== MONITOR DE SAUDE — banner global (shared.js, todas as paginas) ===== */
.health-banner {
  margin: 12px 18px 0;
  border-radius: var(--radius);
  border: 1px solid;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  font-size: 13px;
}
.health-banner.health-crit { background: var(--sell-bg); border-color: var(--sell-border); color: var(--sell-txt); }
.health-banner.health-warn { background: var(--hold-bg); border-color: var(--hold-border); color: var(--hold-txt); }
.health-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; cursor: pointer; user-select: none;
}
.health-ico { font-size: 14px; line-height: 1; }
.health-toggle { margin-left: auto; font-size: 11px; opacity: 0.75; white-space: nowrap; }
.health-body { padding: 0 14px 12px; }
.health-item {
  padding: 9px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.09);
}
.health-item-top { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.health-detail { font-size: 12px; opacity: 0.92; line-height: 1.45; word-break: break-word; }
.health-hint   { font-size: 11px; opacity: 0.7; margin-top: 3px; font-style: italic; }
.health-mute {
  margin-top: 10px; padding: 7px 10px; font-size: 11px;
  background: rgba(0, 0, 0, 0.06); border-radius: 6px;
}
.health-recheck {
  margin-top: 11px; padding: 6px 13px; font-size: 12px; cursor: pointer;
  border: 1px solid currentColor; border-radius: 7px;
  background: transparent; color: inherit; transition: var(--trans);
}
.health-recheck:hover:not(:disabled) { background: rgba(0, 0, 0, 0.07); }
.health-recheck:disabled { opacity: 0.55; cursor: default; }

/* Escuro: as cores de fundo claras do --sell-bg/--hold-bg ficam ilegiveis no
   tema escuro, entao o banner troca para fundo escuro com a cor so na borda. */
body.dark .health-banner.health-crit { background: #3f1d1d; border-color: #7f1d1d; color: #fca5a5; }
body.dark .health-banner.health-warn { background: #3b2f12; border-color: #854d0e; color: #fde047; }
body.dark .health-item  { border-top-color: rgba(255, 255, 255, 0.11); }
body.dark .health-mute  { background: rgba(255, 255, 255, 0.07); }
body.dark .health-recheck:hover:not(:disabled) { background: rgba(255, 255, 255, 0.1); }
