/* ============================================================
   Aba Histórico — estilos (Vanilla CSS, sem build)
   Paleta e fontes alinhadas ao HUD (Orbitron / Fira Code / Exo 2).
   Escopo: tudo prefixado com .hist- para não vazar para o resto do app.
   ============================================================ */

.hist-root {
  /* --- tokens (sobrescreva no :root do app se já existirem) --- */
  --hist-bg:        #090b0f;
  --hist-panel:     #0f1318;
  --hist-panel-2:   #0c1014;
  --hist-border:    #1c212b;
  --hist-border-soft:#171b22;
  --hist-row-hover: #12161c;

  --hist-text:      #eef1f5;
  --hist-text-2:    #c3c9d2;
  --hist-text-3:    #aab1bd;
  --hist-muted:     #6b7280;
  --hist-label:     #5a626f;

  --hist-accent:    #3ad17e;
  --hist-success:   #3ad17e;
  --hist-skipped:   #f2b23c;
  --hist-reverted:  #f0654c;
  --hist-entry:     #34d3bf;
  --hist-exit:      #6aa6fb;

  --hist-mono:    'Fira Code', ui-monospace, SFMono-Regular, Menlo, monospace;
  --hist-display: 'Orbitron', 'Fira Code', sans-serif;
  --hist-sans:    'Exo 2', system-ui, sans-serif;

  font-family: var(--hist-mono);
  color: var(--hist-text);
}
.hist-root *, .hist-modal-overlay * { box-sizing: border-box; }

/* ----------------------------- Card ----------------------------- */
.hist-card {
  background: var(--hist-panel);
  border: 1px solid var(--hist-border);
  border-radius: 14px;
  overflow: hidden;
}
.hist-card-head {
  display:flex; align-items:center; justify-content:space-between;
  gap:16px; flex-wrap:wrap; padding:16px 16px 12px;
}
.hist-card-title {
  font-family: var(--hist-display);
  font-size:13px; font-weight:700; letter-spacing:.1em; color:var(--hist-text);
}
.hist-card-count { font-size:11px; color:var(--hist-muted); }
.hist-head-actions { display:flex; gap:10px; }

.hist-btn {
  background:transparent; border:1px solid #2a2f39; color:var(--hist-text-3);
  padding:8px 13px; border-radius:8px; font:600 11.5px/1 var(--hist-mono);
  display:inline-flex; align-items:center; gap:7px; cursor:pointer; transition:all .15s;
}
.hist-btn:hover { border-color:#3a4150; color:var(--hist-text); }
.hist-btn--danger { color:#d06a59; }
.hist-btn--danger:hover { border-color:rgba(208,106,89,.5); background:rgba(208,106,89,.07); color:#d06a59; }
.hist-btn--danger.is-active { border-color:rgba(240,101,76,.55); background:rgba(240,101,76,.1); color:#f0654c; }
.hist-btn.is-loading { opacity:.6; pointer-events:none; }
.hist-btn svg { width:13px; height:13px; }

/* ----------------------------- Filtros (chips) ----------------------------- */
.hist-filters { display:flex; align-items:center; gap:9px; padding:0 16px 14px; flex-wrap:wrap; }
.hist-filters-label {
  display:inline-flex; align-items:center; gap:7px; flex:0 0 auto; margin-right:2px;
  font:600 11px/1 var(--hist-mono); letter-spacing:.04em; color:var(--hist-label);
}
.hist-filters-label svg { width:13px; height:13px; }
.hist-chip {
  display:inline-flex; align-items:center; gap:9px; padding:9px 15px; border-radius:10px;
  font:600 12.5px/1 var(--hist-mono); cursor:pointer; transition:all .15s;
  background:#12161d; border:1px solid #20262f; color:var(--hist-text-3);
}
.hist-chip:hover { border-color:#3a4350; background:#161b23; color:var(--hist-text-2); }
.hist-chip-dot { width:8px; height:8px; border-radius:50%; flex:0 0 auto; }
.hist-chip-count { font-size:11px; font-weight:700; color:var(--hist-muted); font-variant-numeric:tabular-nums; }
.hist-chip.is-active { color:var(--hist-text); }
.hist-chip[data-filter="all"].is-active     { background:rgba(154,163,178,.16); border-color:rgba(154,163,178,.5); }
.hist-chip[data-filter="sucesso"].is-active  { background:rgba(58,209,126,.13); border-color:rgba(58,209,126,.5); }
.hist-chip[data-filter="pulado"].is-active   { background:rgba(242,178,60,.13); border-color:rgba(242,178,60,.5); }
.hist-chip[data-filter="revertido"].is-active{ background:rgba(240,101,76,.13); border-color:rgba(240,101,76,.5); }
.hist-chip.is-active .hist-chip-count { color:inherit; }

/* segmented control de período (Hoje | Tudo) */
.hist-period {
  display:inline-flex; gap:3px; padding:3px; flex:0 0 auto;
  background:#0d1116; border:1px solid #20262f; border-radius:10px;
}
.hist-seg {
  background:transparent; border:none; color:var(--hist-text-3); cursor:pointer;
  padding:7px 14px; border-radius:7px; font:600 12px/1 var(--hist-mono); transition:all .15s;
}
.hist-seg:hover { color:var(--hist-text-2); }
.hist-seg:focus-visible { outline:2px solid rgba(58,209,126,.5); outline-offset:1px; }
.hist-seg.is-active { background:rgba(58,209,126,.14); color:var(--hist-accent); }
.hist-filters-divider { width:1px; height:22px; background:var(--hist-border); flex:0 0 auto; margin:0 3px; }

/* campo de busca textual — empurrado para a direita da barra de filtros */
.hist-search {
  display:inline-flex; align-items:center; gap:8px; margin-left:auto;
  flex:0 1 250px; min-width:160px; height:38px; padding:0 11px; border-radius:10px;
  background:#0d1116; border:1px solid #20262f; transition:border-color .15s, box-shadow .15s;
}
.hist-search:focus-within { border-color:rgba(58,209,126,.55); box-shadow:0 0 0 2px rgba(58,209,126,.12); }
.hist-search-ico { display:inline-flex; flex:0 0 auto; color:var(--hist-label); }
.hist-search-ico svg { width:14px; height:14px; }
.hist-search-input {
  flex:1 1 auto; min-width:0; background:transparent; border:none; outline:none;
  color:var(--hist-text); font:500 12.5px/1 var(--hist-mono);
}
.hist-search-input::placeholder { color:var(--hist-label); }
.hist-search-clear {
  display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto;
  width:21px; height:21px; padding:0; border:none; border-radius:6px; cursor:pointer;
  background:transparent; color:var(--hist-muted); transition:all .15s;
}
.hist-search-clear:hover { background:#1a2029; color:var(--hist-text-2); }
.hist-search-clear svg { width:13px; height:13px; }

/* na SAÍDA, quando a posição foi ABERTA (entrada) — linha secundária discreta */
.hist-entry-at {
  display:block; margin-top:3px; font:500 10.5px/1.2 var(--hist-mono);
  color:var(--hist-muted); font-variant-numeric:tabular-nums; white-space:nowrap;
}

/* ----------------------------- Tabela (grid) ----------------------------- */
.hist-scroll { overflow-x:auto; }
.hist-grid {
  display:grid;
  grid-template-columns:30px 92px minmax(140px,1.2fr) minmax(150px,1.4fr) 66px 80px minmax(120px,1.5fr) 30px;
  align-items:center; column-gap:12px; min-width:700px;
}
.hist-thead {
  padding:0 16px; height:36px; background:var(--hist-panel-2);
  border-top:1px solid var(--hist-border); border-bottom:1px solid var(--hist-border);
}
.hist-th { font-size:10px; letter-spacing:.13em; text-transform:uppercase; color:var(--hist-label); font-weight:600; }
.hist-th--r { text-align:right; }

.hist-row { padding:13px 16px; cursor:pointer; border-bottom:1px solid var(--hist-border-soft); transition:background .12s; }
.hist-row:hover { background:var(--hist-row-hover); }

.hist-check { width:16px; height:16px; border:1.5px solid #2c323d; border-radius:4px; background:#0d1015; cursor:pointer; position:relative; transition:background .12s, border-color .12s; }
.hist-check:hover { border-color:#3a4150; }
.hist-check.is-checked { background:var(--hist-accent); border-color:var(--hist-accent); }
.hist-check.is-checked::after {
  content:''; position:absolute; left:4px; top:1px; width:5px; height:9px;
  border:solid #06140c; border-width:0 2px 2px 0; transform:rotate(45deg);
}

.hist-datetime { display:flex; flex-direction:column; line-height:1.3; }
.hist-date { font-size:11.5px; color:var(--hist-text-2); font-weight:600; }
.hist-time { font-size:11px; color:var(--hist-muted); }

.hist-asset { display:flex; align-items:center; gap:10px; min-width:0; }
.hist-token { width:30px; height:30px; border-radius:8px; display:flex; align-items:center; justify-content:center;
  font-size:9.5px; font-weight:800; letter-spacing:.02em; flex:0 0 auto; }
.hist-asset-meta { display:flex; flex-direction:column; gap:3px; min-width:0; }
.hist-ticker { font-weight:700; font-size:13px; color:var(--hist-text); }
.hist-op-line { display:flex; align-items:center; gap:7px; }
.hist-op { padding:3px 8px; border-radius:5px; font-size:9.5px; font-weight:700; letter-spacing:.06em; }
.hist-op--entry { background:rgba(52,211,191,.12); color:var(--hist-entry); border:1px solid rgba(52,211,191,.28); }
.hist-op--exit  { background:rgba(106,166,250,.12); color:var(--hist-exit);  border:1px solid rgba(106,166,250,.28); }
.hist-route { font-size:9.5px; color:var(--hist-muted); white-space:nowrap; }

.hist-num { font-size:12.5px; font-weight:600; text-align:right; display:block; font-variant-numeric:tabular-nums; }
.hist-num--pos { color:var(--hist-success); }
.hist-num--neg { color:var(--hist-reverted); }
.hist-num--zero{ color:var(--hist-muted); font-weight:400; }

.hist-detail { color:var(--hist-text-2); font-size:12.5px; display:flex; align-items:center; gap:9px; min-width:0; }
.hist-detail-text { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.hist-detail svg { width:13px; height:13px; color:var(--hist-label); flex:0 0 auto; }

.hist-status { display:flex; align-items:center; gap:10px; min-width:0; }
.hist-status-icon { width:32px; height:32px; border-radius:9px; display:flex; align-items:center; justify-content:center; flex:0 0 auto; }
.hist-status-icon svg { width:15px; height:15px; }
.hist-status-meta { display:flex; flex-direction:column; gap:2px; min-width:0; }
.hist-status-label { font-weight:700; font-size:12px; line-height:1.2; white-space:nowrap; }
.hist-status-code { font-size:9px; color:#646c79; letter-spacing:.02em; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.hist-count { background:#1b2029; color:var(--hist-text-3); font-size:9.5px; padding:2px 6px; border-radius:5px; font-weight:700; flex:0 0 auto; }

.hist-trash { background:transparent; border:1px solid #20262f; border-radius:7px; width:30px; height:30px;
  color:var(--hist-muted); cursor:pointer; display:inline-flex; align-items:center; justify-content:center; }
.hist-trash:hover { color:var(--hist-reverted); border-color:rgba(240,101,76,.45); }
.hist-trash svg { width:14px; height:14px; }
.hist-cell--r { display:flex; justify-content:flex-end; }

/* categorias (cor do ícone/label de status) */
.hist-cat-sucesso   { color:var(--hist-success); }
.hist-cat-pulado    { color:var(--hist-skipped); }
.hist-cat-revertido { color:var(--hist-reverted); }
.hist-status-icon.hist-cat-sucesso   { background:rgba(58,209,126,.12); border:1px solid rgba(58,209,126,.33); }
.hist-status-icon.hist-cat-pulado    { background:rgba(242,178,60,.12); border:1px solid rgba(242,178,60,.33); }
.hist-status-icon.hist-cat-revertido { background:rgba(240,101,76,.12); border:1px solid rgba(240,101,76,.33); }

.hist-empty { padding:48px 20px; text-align:center; color:var(--hist-muted); font-size:12.5px; }

/* ----------------------------- Modal ----------------------------- */
.hist-modal-overlay {
  position:fixed; inset:0; background:rgba(5,7,10,.74); backdrop-filter:blur(3px);
  display:flex; align-items:center; justify-content:center; padding:24px; z-index:1000;
  font-family:var(--hist-mono); animation:hist-overlay-in .15s ease;
}
.hist-modal {
  width:540px; max-width:100%; max-height:88vh; overflow:auto;
  /* redimensionável: arraste o canto inferior direito p/ esticar largura/altura */
  min-width:340px; min-height:240px; resize:both;
  background:var(--hist-panel); border:1px solid #232a34; border-radius:16px;
  box-shadow:0 30px 70px rgba(0,0,0,.65); animation:hist-modal-in .2s cubic-bezier(.2,.8,.2,1); color:var(--hist-text);
}
/* alça de redimensionar — listras diagonais p/ ficar visível no tema escuro */
.hist-modal::-webkit-resizer {
  background: repeating-linear-gradient(135deg,
    transparent 0 2px, var(--hist-muted) 2px 3px);
}
@keyframes hist-overlay-in { from{opacity:0} to{opacity:1} }
@keyframes hist-modal-in { from{opacity:0; transform:translateY(10px) scale(.98)} to{opacity:1; transform:none} }

.hist-modal-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; padding:20px 20px 16px; border-bottom:1px solid var(--hist-border); }
.hist-modal-id { display:flex; align-items:center; gap:13px; min-width:0; }
.hist-token--lg { width:42px; height:42px; border-radius:11px; font-size:11px; }
.hist-modal-ticker { font-weight:800; font-size:17px; color:var(--hist-text); letter-spacing:.01em; }
.hist-modal-sub { font-size:11px; color:#7d8492; }
.hist-modal-close { background:transparent; border:1px solid #20262f; border-radius:8px; width:32px; height:32px;
  color:#8b919c; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; }
.hist-modal-close:hover { color:var(--hist-text); border-color:#3a4150; }

.hist-modal-body { padding:18px 20px 22px; display:flex; flex-direction:column; gap:18px; }

.hist-banner { display:flex; align-items:center; gap:13px; padding:14px 16px; border-radius:12px; }
.hist-banner.hist-cat-sucesso   { background:rgba(58,209,126,.12); border:1px solid rgba(58,209,126,.33); }
.hist-banner.hist-cat-pulado    { background:rgba(242,178,60,.12); border:1px solid rgba(242,178,60,.33); }
.hist-banner.hist-cat-revertido { background:rgba(240,101,76,.12); border:1px solid rgba(240,101,76,.33); }
.hist-banner-icon { width:38px; height:38px; border-radius:10px; display:flex; align-items:center; justify-content:center; background:rgba(0,0,0,.18); border:1px solid currentColor; flex:0 0 auto; }
.hist-banner-icon svg { width:17px; height:17px; }
.hist-banner-label { font-weight:700; font-size:15px; letter-spacing:.02em; }
.hist-banner-code { font-family:var(--hist-mono); font-size:10.5px; color:#8b919c; letter-spacing:.04em; }
.hist-banner-count { margin-left:auto; background:rgba(0,0,0,.25); font-size:11px; padding:4px 9px; border-radius:6px; font-weight:700; }

.hist-metrics { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.hist-metric { background:var(--hist-panel-2); border:1px solid var(--hist-border); border-radius:10px; padding:12px 13px; }
.hist-metric-label { font-size:9.5px; letter-spacing:.1em; text-transform:uppercase; color:var(--hist-label); font-weight:600; margin-bottom:6px; }
.hist-metric-value { font-size:16px; font-weight:700; color:var(--hist-text); font-variant-numeric:tabular-nums; }

.hist-section-title { font-size:10px; letter-spacing:.13em; text-transform:uppercase; color:var(--hist-label); font-weight:700; margin-bottom:9px; }
.hist-explain { margin:0; color:#c8cdd6; font-size:13px; line-height:1.7; font-family:var(--hist-sans); }

.hist-params { display:flex; flex-direction:column; }
.hist-param { display:flex; justify-content:space-between; align-items:baseline; gap:16px; padding:10px 0; border-bottom:1px solid var(--hist-border-soft); }
.hist-param-k { color:#7d8492; font-size:12px; }
.hist-param-v { color:#dce1e8; font-size:12px; font-weight:600; text-align:right; }

.hist-modal-foot { display:flex; align-items:center; justify-content:space-between; gap:14px; padding-top:2px; }
.hist-modal-foot span { font-size:11px; color:var(--hist-muted); }
.hist-foot-actions { display:flex; align-items:center; gap:10px; flex:0 0 auto; }
.hist-modal-bot { display:inline-flex; align-items:center; gap:7px;
  background:transparent; border:1px solid #2a3340; color:var(--hist-text-2);
  padding:10px 14px; border-radius:9px; font:600 12px/1 var(--hist-mono); cursor:pointer;
  letter-spacing:.02em; transition:all .15s; }
.hist-modal-bot:hover { border-color:var(--hist-entry); color:var(--hist-entry); background:rgba(52,211,191,.08); }
.hist-modal-bot svg { width:14px; height:14px; }
.hist-modal-ok { background:var(--hist-accent); border:none; color:#06140c; padding:10px 18px; border-radius:9px;
  font:700 12px/1 var(--hist-mono); cursor:pointer; letter-spacing:.02em; }
.hist-modal-ok:hover { background:#46de8a; }

/* ----------------------------- Paginação ----------------------------- */
.hist-pager {
  display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap;
  padding:13px 16px; border-top:1px solid var(--hist-border); background:var(--hist-panel-2);
}
.hist-pager-size { display:flex; align-items:center; gap:9px; }
.hist-pager-size label {
  font:600 10px/1 var(--hist-mono); letter-spacing:.1em; text-transform:uppercase; color:var(--hist-label);
}
.hist-select {
  background:#12161d; border:1px solid #20262f; color:var(--hist-text-2);
  border-radius:8px; padding:7px 10px; font:600 12px/1 var(--hist-mono); cursor:pointer; transition:border-color .15s;
}
.hist-select:hover { border-color:#3a4350; }
.hist-select:focus-visible { outline:2px solid rgba(58,209,126,.5); outline-offset:1px; }

.hist-pager-nav { display:flex; align-items:center; gap:6px; }
.hist-page-nums { display:flex; align-items:center; gap:4px; }
.hist-page-btn, .hist-page-num {
  background:transparent; border:1px solid #20262f; color:var(--hist-text-3);
  border-radius:8px; cursor:pointer; font:600 12px/1 var(--hist-mono);
  display:inline-flex; align-items:center; gap:5px; transition:all .15s;
}
.hist-page-btn { padding:8px 11px; }
.hist-page-num { min-width:32px; height:32px; justify-content:center; padding:0 6px; font-variant-numeric:tabular-nums; }
.hist-page-btn:hover:not(:disabled), .hist-page-num:hover { border-color:#3a4350; color:var(--hist-text); background:#161b23; }
.hist-page-btn:disabled { opacity:.4; cursor:default; }
.hist-page-btn svg { width:13px; height:13px; }
.hist-page-num.is-active { background:rgba(58,209,126,.14); border-color:rgba(58,209,126,.55); color:var(--hist-accent); }
.hist-page-gap { color:var(--hist-muted); padding:0 3px; font-size:12px; user-select:none; }
.hist-pager-info { font-size:11px; color:var(--hist-muted); font-variant-numeric:tabular-nums; }

/* ----------------------------- Responsivo ----------------------------- */
@media (max-width: 640px) {
  .hist-card-head { padding:14px 14px 10px; }
  .hist-filters { padding:0 14px 12px; gap:7px; }
  .hist-search { margin-left:0; flex-basis:100%; order:10; }
  .hist-thead, .hist-row { padding-left:14px; padding-right:14px; }
  .hist-pager { padding:12px 14px; gap:10px; }
  .hist-pager-nav { order:3; width:100%; justify-content:center; }
}
@media (prefers-reduced-motion: reduce) {
  .hist-modal-overlay, .hist-modal { animation:none; }
}
