@font-face {
  font-family: "Manrope";
  src: url("/static/fonts/manrope-latin.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --black: #000000;
  --blue: #0058FB;
  --ice: #DFE3E8;
  --ice-2: rgba(223, 227, 232, .64);
  --ice-3: rgba(223, 227, 232, .38);
  --line: rgba(223, 227, 232, .12);
  --line-2: rgba(223, 227, 232, .2);
  --panel: #0a0b0d;
  --panel-2: #111317;
  --blue-soft: rgba(0, 88, 251, .16);
  --red: #ff5a5a;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--black); color: var(--ice); }
body {
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--ice-2); }
.error { color: var(--red); min-height: 1.2em; margin: 8px 0 0; }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 20px; background: rgba(0,0,0,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.brand .mark { width: 10px; height: 10px; background: var(--blue); border-radius: 2px; }
.brand .sub { color: var(--ice-2); font-weight: 500; }
.pill { padding: 2px 10px; border: 1px solid var(--line-2); border-radius: 999px; font-weight: 700; font-size: 12px; letter-spacing: .04em; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--ice-3); font-size: 12px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--ice-3); }
.live.on { color: var(--ice-2); }
.live.on i { background: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs button { background: none; border: 0; padding: 7px 12px; border-radius: 8px; color: var(--ice-2); cursor: pointer; font-weight: 600; }
.tabs button.on { color: var(--ice); background: var(--panel-2); }
.tabs button:hover { color: var(--ice); }
button.ghost { background: none; border: 1px solid var(--line-2); padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--ice-2); }
button.ghost:hover { color: var(--ice); border-color: var(--ice-3); }
button.primary { background: var(--blue); border: 0; color: #fff; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-weight: 700; }
button.primary:disabled { opacity: .5; cursor: default; }
.wide { width: 100%; margin-top: 10px; }

main { padding: 16px 20px 40px; max-width: 1480px; margin: 0 auto; }

/* ---------- login ---------- */
.login { display: grid; place-items: center; min-height: 70vh; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.login .card { width: min(380px, 100%); display: grid; gap: 10px; }
.login h1 { margin: 0; font-size: 20px; }
.login input { background: var(--black); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ---------- filtros ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters select, .filters input[type=search] {
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 10px; min-width: 0;
}
.filters input[type=search] { width: 180px; }
.range { display: inline-flex; align-items: center; gap: 8px; color: var(--ice-2); font-size: 13px; }
.range input { accent-color: var(--blue); width: 120px; }
.range output { color: var(--ice); font-weight: 700; min-width: 2ch; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ice-2); font-size: 13px; cursor: pointer; }
.check input { accent-color: var(--blue); }

/* ---------- feed ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.split.solo { grid-template-columns: minmax(0, 1fr); }
.counts { display: flex; gap: 16px; color: var(--ice-3); font-size: 12px; margin-bottom: 8px; }
.counts b { color: var(--ice-2); font-weight: 700; }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.item {
  display: grid; grid-template-columns: 46px minmax(0, 1fr); gap: 12px; align-items: center;
  padding: 11px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color .15s, background .15s;
}
.item:hover { border-color: var(--line-2); }
.item.sel { border-color: var(--blue); background: #05070c; }
.item.fresh { animation: flash 2.4s ease-out; }
.item.closed { opacity: .62; }
@keyframes flash { from { background: var(--blue-soft); } to { background: var(--panel); } }
.score {
  width: 46px; height: 46px; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; font-size: 17px; border: 1px solid var(--line-2); color: var(--ice-2);
  font-variant-numeric: tabular-nums;
}
.score.t2 { border-color: var(--blue); color: var(--ice); }
.score.t3 { background: var(--blue); border-color: var(--blue); color: #fff; }
.title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; color: var(--ice-3); font-size: 12px; margin-top: 2px; }
.meta .act { color: var(--ice-2); }
.meta .act::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--blue); margin-right: 5px; vertical-align: 1px; }
.meta .al { color: var(--ice); font-weight: 700; }
.dir-up::before { content: "↑ "; }
.dir-down::before { content: "↓ "; }
.empty { padding: 30px 0; text-align: center; }

/* ---------- detalhe ---------- */
.detail {
  position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
}
.detail { min-width: 0; overflow-wrap: anywhere; }
.detail table { table-layout: fixed; }
.detail th:first-child, .detail td:first-child { width: 28%; }
.detail td.num, .detail th:last-child { width: 64px; }
.detail h2 { margin: 0 0 4px; font-size: 18px; line-height: 1.3; }
.detail h3 { margin: 20px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ice-3); font-weight: 700; }
.detail .close { float: right; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--ice-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ice-3); font-weight: 600; font-size: 12px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 800; border-bottom: 0; }
details.ev { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; }
details.ev summary { padding: 8px 10px; cursor: pointer; font-size: 13px; }
details.ev summary .src { color: var(--ice-3); font-size: 12px; margin-left: 6px; }
pre { margin: 0; padding: 10px; background: var(--black); border-top: 1px solid var(--line); overflow: auto; font-size: 12px; max-height: 320px; color: var(--ice-2); }
.timeline { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--line-2); }
.timeline li { padding: 0 0 10px 14px; position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -4px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--ice-3); }
.timeline li.k-opened::before, .timeline li.k-escalated::before { background: var(--blue); }
.timeline .when { color: var(--ice-3); font-size: 12px; }

/* ---------- detectores ---------- */
.intro { margin: 0 0 14px; max-width: 900px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; }
.det h4 { margin: 0; font-size: 15px; display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.det .tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.tag { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--ice-2); }
.tag.blue { border-color: var(--blue); color: var(--ice); }
.tag.warn { border-color: var(--red); color: var(--red); }
.det p { margin: 6px 0; font-size: 13px; color: var(--ice-2); }
.det .src { font-size: 12px; color: var(--ice-3); }
.params { display: grid; grid-template-columns: 1fr 110px; gap: 6px 10px; margin-top: 10px; align-items: center; font-size: 13px; }
.params label { color: var(--ice-2); }
.params input[type=number] { background: var(--black); border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; width: 100%; text-align: right; }
.params input[type=checkbox] { accent-color: var(--blue); justify-self: end; width: 16px; height: 16px; }
.params .changed { border-color: var(--blue) !important; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ice-2); font-weight: 500; }
.switch input { accent-color: var(--blue); }

/* ---------- sistema ---------- */
.sys { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.sys .card h4 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ice-3); }
.ok { color: var(--ice); }
.bad { color: var(--red); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--blue); padding: 10px 16px; border-radius: 10px; z-index: 30; max-width: 90vw; }

/* ---------- responsivo ---------- */
@media (max-width: 960px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .detail { position: fixed; inset: 0; top: 0; max-height: none; border-radius: 0; z-index: 20; padding: 16px 16px 40px; }
  .sys { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .top { padding: 10px 12px; gap: 10px; }
  .tabs { margin-left: 0; width: 100%; order: 5; }
  .tabs button { flex: 1; }
  main { padding: 12px; }
  .filters input[type=search] { width: 100%; }
  .filters select { flex: 1 1 45%; }
  .grid { grid-template-columns: minmax(0, 1fr); }
}
