/*
 * THREAT — consola de abuz outbound.
 *
 * Dark-only, deliberat: e o unealta de operare care sta deschisa pe un perete.
 * Culorile de serie sunt paleta categorica de referinţa (coloana dark) in
 * ordinea documentata a sloturilor, validata pe suprafaţa --surface
 * (worst adjacent CVD ΔE 8.4). Paleta de status e rezervata pentru stare si nu
 * se refoloseste niciodata ca serie.
 */

:root {
  color-scheme: dark;

  --plane:      #0d0d0d;   /* planul paginii */
  --surface:    #1a1a19;   /* suprafaţa cardului si a graficelor */
  --surface-2:  #201f1e;   /* rânduri alternante, câmpuri */
  --surface-3:  #262624;

  --ink-1:      #ffffff;
  --ink-2:      #c3c2b7;
  --ink-3:      #898781;   /* axe, etichete recesive */

  --grid:       #2c2c2a;   /* hairline, solid, niciodata punctat */
  --axis:       #383835;
  --hairline:   rgba(255, 255, 255, 0.10);

  /* Sloturi categorice — ordinea e mecanismul de siguranţa CVD, nu cosmetica. */
  --s1: #3987e5;  --s2: #d95926;  --s3: #199e70;  --s4: #c98500;
  --s5: #d55181;  --s6: #008300;  --s7: #9085e9;
  --s-noise: #6b6a64;  --s-other: #898781;

  /* Status — rezervat. Mereu insoţit de icoana + eticheta, niciodata culoare singura. */
  --st-good:     #0ca30c;
  --st-warning:  #fab219;
  --st-serious:  #ec835a;
  --st-critical: #d03b3b;

  --radius: 8px;
  --gap: 14px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

/*
 * Atributul `hidden` trebuie sa bata orice `display` declarat de noi.
 * Fara asta, `.drawer { display: flex }` si `.chip { display: inline-flex }`
 * cаştigau faţa de regula `[hidden]` din UA stylesheet, iar sertarul ramânea
 * vizibil permanent, ingustând toata pagina.
 */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink-2);
  font: 400 13.5px/1.5 var(--font);
}

h1, h2, h3 { margin: 0; color: var(--ink-1); font-weight: 600; }
a { color: inherit; }

/* ─────────────── autentificare ─────────────── */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card { width: 100%; max-width: 360px; }
.login-head { text-align: center; margin-bottom: 26px; }
.login-head h1 { font-size: 26px; letter-spacing: 5px; margin-top: 10px; }
.login-head p { margin: 6px 0 0; color: var(--ink-3); font-size: 12.5px; }
.login-card form { display: grid; gap: 9px; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: var(--radius); padding: 20px; }
.login-card label { color: var(--ink-3); font-size: 12px; }
.login-error { margin: 0; color: var(--st-critical); font-size: 12.5px; }

.brand-mark {
  display: inline-block; width: 11px; height: 11px; border-radius: 3px;
  background: var(--st-critical); box-shadow: 0 0 0 3px rgba(208, 59, 59, 0.16);
}

/* ─────────────── cromul aplicaţiei ─────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 10px 18px; background: var(--plane);
  border-bottom: 1px solid var(--hairline);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.brand { color: var(--ink-1); font-weight: 700; letter-spacing: 3px; font-size: 14px; }
.brand-sub { color: var(--ink-3); font-size: 12px; font-family: var(--mono); }

/* Sanatatea conductei. O conducta moarta nu trebuie sa arate ca o reţea liniştita. */
.pipe {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 10px; border-radius: 99px; font-size: 12px;
  border: 1px solid var(--hairline); background: var(--surface);
}
.pipe-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--ink-3); }
.pipe--live     .pipe-dot { background: var(--st-good); animation: pulse 2.4s ease-in-out infinite; }
.pipe--live     .pipe-text { color: var(--ink-2); }
.pipe--lagging  .pipe-dot { background: var(--st-warning); }
.pipe--lagging  .pipe-text { color: var(--st-warning); }
.pipe--stale    .pipe-dot { background: var(--st-critical); }
.pipe--stale    .pipe-text { color: var(--st-critical); }
.pipe--stale    { border-color: rgba(208, 59, 59, 0.4); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .pipe--live .pipe-dot { animation: none; } }

/* Un singur rând de filtre, deasupra a tot ce delimiteaza. */
.filterbar {
  position: sticky; top: 45px; z-index: 25;
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px;
  padding: 11px 18px; background: var(--plane);
  border-bottom: 1px solid var(--hairline);
}
.filterbar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.seg { display: inline-flex; border: 1px solid var(--hairline); border-radius: 6px; overflow: hidden; }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--ink-3);
  padding: 6px 11px; font: 500 12.5px var(--font); cursor: pointer;
  border-right: 1px solid var(--hairline);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-2); color: var(--ink-2); }
.seg button.is-on { background: var(--surface-3); color: var(--ink-1); }

.field { display: grid; gap: 3px; }
.field--grow { flex: 1 1 200px; min-width: 160px; }
.field-label { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
select, input[type="search"], input[type="password"], textarea {
  appearance: none; background: var(--surface-2); color: var(--ink-1);
  border: 1px solid var(--hairline); border-radius: 6px;
  padding: 6px 9px; font: 400 13px var(--font); width: 100%;
}
/* appearance:none scoate si caretul nativ — il redesenam, altfel un select
   arata identic cu un input de text. */
select {
  padding-right: 26px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
select:focus-visible, input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--s1); outline-offset: 1px;
}
input.is-error { border-color: var(--st-critical); }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-size: 12.5px; padding-bottom: 6px; }

.btn {
  appearance: none; display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-3); color: var(--ink-1);
  border: 1px solid var(--hairline); border-radius: 6px;
  padding: 6px 12px; font: 500 12.5px var(--font); cursor: pointer; text-decoration: none;
}
.btn:hover { background: #2f2f2c; }
.btn--ghost { background: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 4px 9px; font-size: 12px; }
.btn[aria-pressed="true"] { background: var(--surface-3); color: var(--ink-1); }
.btn:disabled { opacity: 0.5; cursor: default; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-3); border: 1px solid var(--hairline);
  border-radius: 99px; padding: 4px 10px; font: 500 12px var(--mono); color: var(--ink-1);
}
.chip button { appearance: none; border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 13px; padding: 0; }

/* ─────────────── aşezare ─────────────── */
.wrap { max-width: 1680px; margin: 0 auto; padding: var(--gap) 18px 40px; display: grid; gap: var(--gap); }
.kpi { display: grid; gap: var(--gap); grid-template-columns: 1.25fr 1fr 1fr 1fr; }
/* align-items:start — altfel grid-ul intinde cardul scund la inaltimea
   vecinului si lasa un gol mare sub grafic. */
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: 1.35fr 1fr; align-items: start; }
@media (max-width: 1100px) { .kpi, .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 680px)  { .kpi, .grid-2 { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); min-width: 0; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--hairline);
}
.card-head h2 { font-size: 13px; letter-spacing: 0.02em; }
.card-sub { color: var(--ink-3); font-size: 12px; }
.card-body { padding: 14px; }
.card-body.no-pad { padding: 0; }

/* Figura eroica: exact una pe ecran. Cifre proporţionale, nu tabulare. */
.card--hero { padding: 14px; display: grid; align-content: center; gap: 2px; }
.hero-label { color: var(--ink-3); font-size: 12px; }
.hero-figure { color: var(--ink-1); font-size: 52px; font-weight: 600; line-height: 1.05; }
.hero-foot { color: var(--ink-3); font-size: 12px; min-height: 18px; }

.stat { padding: 14px; display: grid; gap: 4px; align-content: start; }
.stat-label { color: var(--ink-3); font-size: 12px; }
.stat-value { color: var(--ink-1); font-size: 27px; font-weight: 600; line-height: 1.1; }
.stat-spark { height: 26px; }
.stat-spark:empty { height: 0; }   /* trend-ul e opţional: fara el, fara gaura */
.stat-foot { color: var(--ink-3); font-size: 11.5px; min-height: 17px; }

/* ─────────────── tabele ─────────────── */
.table-scroll { overflow-x: auto; }
.table-scroll--tall { max-height: 360px; overflow-y: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.tbl th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; color: var(--ink-3); font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 8px 10px; background: var(--surface);
  border-bottom: 1px solid var(--grid); white-space: nowrap;
}
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
/* Cifrele se aliniaza vertical in coloane, deci tabular — dar numai aici. */
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-empty td { color: var(--ink-3); text-align: center; padding: 22px; }
.mono { font-family: var(--mono); }
.ip { font-family: var(--mono); color: var(--ink-1); }
.ip-btn { appearance: none; background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-family: var(--mono); color: var(--ink-1); text-align: left; }
.ip-btn:hover { text-decoration: underline; }
.sig { color: var(--ink-2); display: block; max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dim { color: var(--ink-3); }
.col-risk { width: 122px; } .col-spark { width: 108px; } .col-act { width: 150px; }

/* Cheia de categorie: culoarea sta pe marcaj, textul ramâne pe token de text. */
.cat-key { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cat-swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }

/* Metru de risc: umplerea poarta severitatea, pista e un pas mai deschis din
   aceeasi rampa, ca starea sa se citeasca pe toata lungimea barei. */
.meter { display: flex; align-items: center; gap: 8px; }
.meter-track { position: relative; flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.meter-fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; }
.meter-num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-1); min-width: 2.1em; text-align: right; font-size: 12.5px; }
.meter-icon { font-size: 10px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px; font-size: 11.5px;
  border: 1px solid var(--hairline); background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge--open      { color: var(--ink-1); border-color: rgba(255,255,255,0.22); }
.badge--reopened  { color: var(--st-critical); border-color: rgba(208,59,59,0.45); }
.badge--acked     { color: var(--st-warning); }
.badge--notified  { color: var(--s1); }
.badge--suspended { color: var(--st-good); }
.badge--false_positive { color: var(--ink-3); }

/* ─────────────── grafice ─────────────── */
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-bottom: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); cursor: default; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.legend-num { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.is-loading { opacity: 0.45; transition: opacity 120ms; }   /* refetch ţine cadrul, fara skeleton */

.tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: #111110; border: 1px solid var(--hairline); border-radius: 6px;
  padding: 8px 10px; font-size: 12px; color: var(--ink-2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5); max-width: 280px;
}
.tip-head { color: var(--ink-3); font-size: 11px; margin-bottom: 5px; }
.tip-row { display: flex; align-items: center; gap: 7px; justify-content: space-between; }
/* Valoarea conduce, numele seriei urmeaza — invers faţa de legenda. */
.tip-val { color: var(--ink-1); font-weight: 600; font-variant-numeric: tabular-nums; }
.tip-name { color: var(--ink-3); }
.tip-key { width: 12px; height: 2px; border-radius: 2px; flex: none; }

/* ─────────────── buget de zgomot ─────────────── */
.noise-list { max-height: 430px; overflow-y: auto; }
.noise-list > div { padding: 10px 14px; border-bottom: 1px solid var(--grid); }
.noise-list > div:last-child { border-bottom: 0; }
.noise-row { display: flex; align-items: center; gap: 10px; }
.noise-main { flex: 1; min-width: 0; }
.noise-sig { color: var(--ink-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.noise-meta { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.noise-bar { height: 4px; border-radius: 99px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.noise-bar span { display: block; height: 100%; border-radius: 99px; }
.snippet {
  margin-top: 9px; background: var(--plane); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 9px 10px;
}
.snippet-title { color: var(--ink-3); font-size: 11px; margin-bottom: 6px; }
.snippet pre { margin: 0; font: 400 11.5px/1.65 var(--mono); color: var(--ink-2); white-space: pre-wrap; word-break: break-word; }

/* ─────────────── sertar ─────────────── */
.drawer-veil { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.55); }
.drawer {
  position: fixed; inset: 0 0 0 auto; z-index: 50; width: min(560px, 100%);
  background: var(--surface); border-left: 1px solid var(--hairline);
  display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--hairline);
}
.drawer-head h2 { font-family: var(--mono); font-size: 15px; }
.drawer-body { padding: 16px; overflow-y: auto; display: grid; gap: 18px; }
.drawer-sec h3 { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.kv-item { background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 6px; padding: 9px 10px; }
.kv-label { color: var(--ink-3); font-size: 11px; }
.kv-val { color: var(--ink-1); font-size: 17px; font-weight: 600; }
.kv-val small { display: block; font-size: 11.5px; font-weight: 400; color: var(--ink-3); line-height: 1.35; }

.pager { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--hairline); }
.pager-info { color: var(--ink-3); font-size: 12px; margin-left: auto; font-variant-numeric: tabular-nums; }

.prose { font-size: 13px; line-height: 1.62; }
.prose--muted { color: var(--ink-3); }
.prose h2 { font-size: 13.5px; margin: 14px 0 5px; }
.prose ul { margin: 6px 0; padding-left: 18px; }
.prose li { margin: 3px 0; }
.prose code { font-family: var(--mono); font-size: 12px; background: var(--surface-2); padding: 1px 4px; border-radius: 3px; }
.prose strong { color: var(--ink-1); }

.foot { color: var(--ink-3); font-size: 11.5px; text-align: center; padding-top: 4px; }

.spinner {
  display: inline-block; width: 11px; height: 11px; border-radius: 99px;
  border: 2px solid var(--ink-3); border-top-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
