/* Signals panel - RTL, dark.
   Status colours (--win / --loss) were validated against --panel for
   colour-vision deficiency. Do not swap them for green/red: that pair
   separates at deutan dE 3.5, this one at 13.6. Every use of them is
   paired with a glyph and a label so colour never carries meaning alone. */

:root {
  --bg:      #0f1216;
  --panel:   #171b21;
  --panel-2: #1e242c;
  --line:    #2a323c;
  --line-2:  #222932;

  --text:    #e6eaf0;
  --muted:   #8b97a6;
  --faint:   #5d6774;

  --accent:  #4c8dff;

  --win:     #35a89d;
  --loss:    #dd6a35;
  --pending: #3a434f;
  --notrade: #262d36;

  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Rubik, "Arial Hebrew", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h2 { margin: 0; font-size: 0.95rem; font-weight: 600; }

.muted  { color: var(--muted); font-size: 0.85em; }
.nowrap { white-space: nowrap; }
.num    { font-variant-numeric: tabular-nums; text-align: left; direction: ltr; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar .brand strong { font-size: 1.05rem; }
.topbar .brand .muted { margin-inline-start: 8px; }
.topbar nav { display: flex; align-items: center; gap: 18px; font-size: 0.88rem; }

.pipe-status { color: var(--muted); font-size: 0.8rem; display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot-ok   { background: var(--win); }
.dot-warn { background: var(--loss); }
.dot-idle { background: var(--faint); }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

.flash {
  background: #16302e;
  border: 1px solid #2c5551;
  color: #bfe9e4;
  padding: 8px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

/* ---------- KPI row ---------- */

.kpis {
  display: grid;
  grid-template-columns: 1.5fr repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.kpi-label { color: var(--muted); font-size: 0.78rem; }
.kpi-value {
  font-size: 1.9rem;
  font-weight: 600;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { color: var(--faint); font-size: 0.76rem; }
.kpi-sub a { color: var(--accent); }

.kpi-hero { background: linear-gradient(180deg, #1a2028, var(--panel)); }
.kpi-hero .kpi-value { font-size: 3rem; }
.kpi-hero .pct { font-size: 1.4rem; color: var(--muted); margin-inline-start: 2px; }

.kpi-value.win  { color: var(--win); }
.kpi-value.loss { color: var(--loss); }
.thin-flag { color: var(--loss); font-style: normal; }

/* ---------- filters ---------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 18px;
}
.filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

input, select, button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
}
input:focus, select:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; font-weight: 500; }
button:hover { filter: brightness(1.1); }
.btn-link { align-self: center; font-size: 0.85rem; color: var(--muted); }

/* ---------- charts ---------- */

.charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.charts .card:first-child { grid-column: 1 / -1; }

.card {
  margin: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
}
.card figcaption { margin-bottom: 14px; }
.card figcaption p { margin: 4px 0 0; }

.chart-empty { color: var(--faint); font-size: 0.85rem; margin: 4px 0 0; }

svg.strip, svg.bars { display: block; overflow: visible; }
svg.strip .cell { transition: opacity .12s; }
svg.strip:hover .cell { opacity: 0.45; }
svg.strip .cell:hover { opacity: 1; stroke: var(--text); stroke-width: 1.5; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  font-size: 0.78rem;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw-win      { background: var(--win); }
.sw-loss     { background: var(--loss); }
.sw-pending  { background: var(--pending); }
.sw-no_trade { background: var(--notrade); }

/* ---------- table ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
table { border-collapse: collapse; width: 100%; min-width: 940px; }

th, td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--line-2);
  vertical-align: middle;
}
th {
  background: var(--panel-2);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody tr:hover { background: #1b212a; }
tbody tr:last-child td { border-bottom: none; }

/* a 3px edge marks decided rows; the select still carries the word */
.row-win  td:first-child { box-shadow: inset -3px 0 0 var(--win); }
.row-loss td:first-child { box-shadow: inset -3px 0 0 var(--loss); }
.row-no_trade { opacity: 0.5; }

.col-outcome { min-width: 250px; }
.outcome-form { display: flex; gap: 6px; align-items: center; }
.outcome-form select { padding: 5px 8px; }
.outcome-form input[type=text] { padding: 5px 8px; width: 120px; font-size: 0.85rem; }

.oc-win  { border-color: var(--win); }
.oc-loss { border-color: var(--loss); }

.empty {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--muted);
  line-height: 1.9;
}

.pager {
  display: flex;
  gap: 18px;
  justify-content: center;
  align-items: center;
  padding: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- webhook log ---------- */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-family: ui-monospace, Consolas, monospace;
  background: var(--panel-2);
  border: 1px solid var(--line);
}
.b-accepted  { background: #16302e; border-color: #2c5551; color: #bfe9e4; }
.b-duplicate { background: #2b2a1c; border-color: #524d2c; color: #e8dfa8; }
.b-bad_secret, .b-bad_ip, .b-error, .b-invalid, .b-bad_json {
  background: #33211a; border-color: #5c3a29; color: #f4cdb6;
}

pre.raw {
  margin: 0;
  max-width: 620px;
  max-height: 120px;
  overflow: auto;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- login ---------- */

.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 1.3rem; }
.login-card p  { margin: -10px 0 6px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; color: var(--muted); }
.login-card button { margin-top: 6px; padding: 10px; }

.alert {
  background: #33211a;
  border: 1px solid #5c3a29;
  color: #f4cdb6;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.88rem;
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .kpis   { grid-template-columns: repeat(2, 1fr); }
  .charts { grid-template-columns: 1fr; }
  .charts .card:first-child { grid-column: auto; }
}
@media (max-width: 700px) {
  main { padding: 12px; }
  .topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .topbar nav { justify-content: space-between; }
  .kpis { grid-template-columns: 1fr; }
  .kpi-hero .kpi-value { font-size: 2.4rem; }
}
