:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --line: #2a2f3a;
  --txt: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #e23744;
  --accent-soft: #e2374422;
  --good: #35c46b;
  --warn: #e0a83b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--txt);
}
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { font-weight: 650; letter-spacing: .2px; display: flex; align-items: center; gap: 9px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
.src { font-size: 12px; color: var(--muted); }
.src b { color: var(--txt); }

.controls {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  justify-content: space-between; padding: 14px 20px;
}
.dates, .filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.controls label { color: var(--muted); font-size: 12px; }
.controls input[type=date], .controls input[type=search], .controls input[type=number] {
  background: var(--panel); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.controls input[type=search] { min-width: 240px; }
.controls input[type=number] { width: 68px; }
.presets { display: flex; gap: 4px; }
.presets button {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 7px 11px; cursor: pointer; font-size: 12px;
}
.presets button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--txt); }

.kpis { display: flex; gap: 12px; padding: 4px 20px 14px; flex-wrap: wrap; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 16px; min-width: 150px;
}
.kpi .label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 22px; font-weight: 680; margin-top: 3px; }

.table-wrap { padding: 0 20px 40px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 880px; }
thead th {
  text-align: left; color: var(--muted); font-weight: 600; font-size: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
  white-space: nowrap; position: sticky; top: 57px; background: var(--bg);
}
thead th.num { text-align: right; }
thead th.img-col { cursor: default; width: 52px; }
thead th[data-key]:hover { color: var(--txt); }
thead th.sorted-asc::after { content: " ▲"; color: var(--accent); }
thead th.sorted-desc::after { content: " ▼"; color: var(--accent); }

tbody tr { border-bottom: 1px solid #23272f; cursor: pointer; }
tbody tr:hover { background: var(--panel); }
tbody td { padding: 9px 12px; vertical-align: middle; }
tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td.txt-title { font-weight: 560; max-width: 320px; }
tbody td.txt-handle { color: var(--muted); font-size: 12px; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--line); }
.conv { font-weight: 620; }
.conv.hi { color: var(--good); }
.conv.lo { color: var(--warn); }
.conv.na { color: var(--muted); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

.modal {
  position: fixed; inset: 0; background: #000a; display: flex;
  align-items: center; justify-content: center; z-index: 20; padding: 20px;
}
/* O atributo `hidden` precisa vencer o display:flex acima — senão o modal
   fica SEMPRE na tela cobrindo o dashboard e não fecha. */
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; width: min(880px, 96vw);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
#modal-title { font-weight: 640; }
#modal-close {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt);
  font-size: 16px; line-height: 1; cursor: pointer; border-radius: 8px;
  width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
}
#modal-close:hover { background: var(--accent-soft); border-color: var(--accent); }
.metric-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.metric-tabs button {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 12px;
}
.metric-tabs button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--txt); }
#chart {
  display: block; width: 100%; aspect-ratio: 820 / 320; height: auto;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
}

.foot { padding: 0 20px 30px; color: var(--muted); font-size: 12px; }

/* topbar direita + sair */
.topbar-right { display: flex; align-items: center; gap: 16px; }
.logout {
  color: var(--muted); font-size: 12px; text-decoration: none;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px;
}
.logout:hover { color: var(--txt); border-color: var(--accent); }

/* página de login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 26px; width: min(360px, 94vw); display: flex; flex-direction: column; gap: 14px;
}
.login-brand { font-weight: 680; display: flex; align-items: center; gap: 9px; font-size: 16px; }
.login-sub { color: var(--muted); font-size: 13px; margin: -4px 0 6px; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field span { color: var(--muted); font-size: 12px; }
.login-field input {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--txt);
  border-radius: 8px; padding: 10px 12px; font-size: 14px;
}
.login-field input:focus { outline: none; border-color: var(--accent); }
.login-btn {
  margin-top: 6px; background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.login-btn:hover { filter: brightness(1.07); }
.login-erro { color: var(--accent); font-size: 13px; text-align: center; margin: 2px 0 0; }
