:root {
  --ink: #0a0e12;
  --panel: #10161d;
  --panel-alt: #151d25;
  --hairline: #232d38;
  --hairline-soft: #1a232c;
  --text: #e7ecf0;
  --muted: #7e8c99;
  --muted-dim: #556270;
  --teal: #35d0a0;
  --teal-dim: #1f6e58;
  --amber: #f2b84b;
  --amber-dim: #7a5f27;
  --red: #e8574a;
  --red-dim: #7a352e;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-display);
  min-height: 100vh;
}

body {
  background-image:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(53, 208, 160, 0.06), transparent),
    radial-gradient(ellipse 50% 30% at 100% 20%, rgba(242, 184, 75, 0.04), transparent);
  padding: 0 0 32px;
}

::selection { background: var(--teal-dim); color: #fff; }

/* faint scanline texture — one deliberate touch of the "broadcast" motif */
.scanline {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.008),
    rgba(255, 255, 255, 0.008) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.5;
}

/* ============== TOPBAR ============== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--hairline);
  position: relative;
  z-index: 1;
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0;
}

.pulse-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted-dim);
  flex-shrink: 0;
}
.pulse-dot.online {
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(53, 208, 160, 0.6);
  animation: pulse 2s infinite;
}
.pulse-dot.offline { background: var(--red); }

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(53, 208, 160, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(53, 208, 160, 0); }
  100% { box-shadow: 0 0 0 0 rgba(53, 208, 160, 0); }
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}
.divider { color: var(--hairline); }
.clock { color: var(--text); }
.conn-state.ok { color: var(--teal); }
.conn-state.err { color: var(--red); }

/* ============== STAT STRIP ============== */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1px;
  background: var(--hairline);
  border-bottom: 1px solid var(--hairline);
  position: relative;
  z-index: 1;
}

.stat-block {
  background: var(--panel);
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 500;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}
.stat-of { font-size: 15px; color: var(--muted-dim); }
.accent-ok { color: var(--teal); }
.accent-bad { color: var(--red); }
.mono-small { font-size: 15px; font-weight: 500; color: var(--muted); }

/* ============== LAYOUT ============== */
.layout {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 1px;
  background: var(--hairline);
  position: relative;
  z-index: 1;
}

.panel {
  background: var(--ink);
  padding: 18px 22px 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

.panel-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--hairline);
  border-radius: 20px;
  padding: 2px 9px;
}

.filter-input {
  background: var(--panel-alt);
  border: 1px solid var(--hairline);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 12.5px;
  padding: 7px 11px;
  border-radius: 6px;
  width: 220px;
  outline: none;
}
.filter-input:focus { border-color: var(--teal-dim); }
.filter-input::placeholder { color: var(--muted-dim); }

.empty-state {
  color: var(--muted-dim);
  font-size: 13px;
  padding: 20px 0;
}

/* ============== SENDER GRID ============== */
.sender-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.sender-card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 13px 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: border-color 0.15s ease;
}
.sender-card:hover { border-color: var(--hairline-soft); }
.sender-card.is-live { border-color: var(--teal-dim); }

.sender-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sender-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--panel-alt);
  border: 1px solid var(--hairline-soft);
}

.sender-id {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.sender-handle {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sender-name {
  font-size: 11.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge.connected { background: rgba(53, 208, 160, 0.12); color: var(--teal); }
.status-badge.disconnected { background: rgba(232, 87, 74, 0.12); color: var(--red); }
.status-badge.inactive { background: rgba(126, 140, 153, 0.12); color: var(--muted); }

.sender-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.sender-meta-row b { color: var(--text); font-weight: 500; }

.sender-stats {
  display: flex;
  gap: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--hairline-soft);
}
.sender-stat { display: flex; flex-direction: column; gap: 2px; }
.sender-stat-label { font-size: 9.5px; color: var(--muted-dim); }
.sender-stat-value { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.sender-stat-value.ok { color: var(--teal); }
.sender-stat-value.bad { color: var(--red); }

.sender-campaign-tag {
  font-size: 10.5px;
  color: var(--amber);
  background: rgba(242, 184, 75, 0.1);
  border-radius: 4px;
  padding: 3px 7px;
  display: inline-block;
  width: fit-content;
}

/* ============== CAMPAIGN LIST ============== */
.campaign-list { display: flex; flex-direction: column; gap: 10px; }

.campaign-card {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 13px 14px;
}

.campaign-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.campaign-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.campaign-status {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: lowercase;
}
.campaign-status.running { background: rgba(242, 184, 75, 0.12); color: var(--amber); }
.campaign-status.completed { background: rgba(53, 208, 160, 0.12); color: var(--teal); }
.campaign-status.failed { background: rgba(232, 87, 74, 0.12); color: var(--red); }
.campaign-status.paused, .campaign-status.stopped { background: rgba(126, 140, 153, 0.12); color: var(--muted); }
.campaign-status.draft { background: rgba(126, 140, 153, 0.08); color: var(--muted-dim); }

.progress-track {
  height: 5px;
  background: var(--hairline-soft);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-fill { height: 100%; background: var(--teal); border-radius: 4px; transition: width 0.4s ease; }
.progress-fill.has-failed { background: linear-gradient(to right, var(--teal), var(--red)); }

.campaign-meta {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
}
.campaign-meta span b { color: var(--text); font-weight: 500; }

/* ============== LOG STREAM ============== */
.log-panel { position: relative; z-index: 1; margin-top: 1px; }

.log-stream {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column-reverse;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--panel);
}

.log-row {
  display: grid;
  grid-template-columns: 78px 64px 1fr 1fr;
  gap: 12px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--hairline-soft);
  align-items: center;
}
.log-row:first-child { border-bottom: none; }

.log-time { color: var(--muted-dim); }
.log-status { font-weight: 600; text-transform: lowercase; }
.log-status.success { color: var(--teal); }
.log-status.failed { color: var(--red); }
.log-status.skipped { color: var(--amber); }
.log-sender { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-target { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============== UTIL ============== */
.hidden { display: none !important; }

/* ============== LOGIN SCREEN (di luar) ============== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  position: relative;
  z-index: 1;
}

.login-wrap {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 0;
  max-width: 920px;
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: 14px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.login-brand {
  padding: 34px 32px;
  background:
    radial-gradient(ellipse 70% 60% at 0% 0%, rgba(53, 208, 160, 0.09), transparent),
    var(--ink);
  border-right: 1px solid var(--hairline);
}

.brand-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--teal);
  background: rgba(53, 208, 160, 0.1);
  border: 1px solid var(--teal-dim);
  border-radius: 20px;
  padding: 3px 10px;
  margin-bottom: 14px;
}
.brand-tag-small { margin: 0 0 0 2px; padding: 2px 8px; font-size: 9px; }

.login-brand h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}

.brand-desc {
  font-size: 13px;
  line-height: 1.6;
  color: var(--muted);
  margin: 0 0 20px;
  max-width: 42ch;
}

.feature-list {
  list-style: none;
  margin: 0 0 26px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.feature-list li {
  font-size: 12.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 9px;
}
.feature-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-ok { background: var(--teal); }
.dot-amber { background: var(--amber); }
.dot-bad { background: var(--red); }

.login-ticker {
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 14px 16px 12px;
}

.ticker-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.ticker-live { color: var(--teal); }

.ticker-stats {
  display: flex;
  gap: 20px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline-soft);
}
.ticker-stats > div { display: flex; flex-direction: column; gap: 2px; }
.ticker-num { font-family: var(--font-mono); font-size: 16px; font-weight: 600; color: var(--text); }
.ticker-label { font-size: 10px; color: var(--muted-dim); }

.login-box {
  padding: 34px 32px;
  display: flex;
  flex-direction: column;
  gap: 11px;
  justify-content: center;
}
.auth-label { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 8px; }
.login-box input {
  background: var(--ink);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 13.5px;
  outline: none;
}
.login-box input:focus { border-color: var(--teal-dim); }
.login-box button {
  background: var(--teal-dim);
  color: #eafff6;
  border: none;
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s ease;
}
.login-box button:hover:not(:disabled) { background: var(--teal); color: #06120d; }
.login-box button:disabled { opacity: 0.6; cursor: default; }
.auth-error { color: var(--red); font-size: 12px; min-height: 14px; margin: 0; }
.login-hint { font-size: 11px; color: var(--muted-dim); margin: 6px 0 0; }

.logout-btn {
  background: none;
  border: 1px solid var(--hairline);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
}
.logout-btn:hover { color: var(--red); border-color: var(--red-dim); }

@media (max-width: 760px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { border-right: none; border-bottom: 1px solid var(--hairline); }
}

/* ============== TRADING CHART ============== */
.chart-panel { position: relative; z-index: 1; margin-top: 1px; }
.chart-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.legend-dot { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.legend-ok { background: var(--teal); }
.legend-bad { background: var(--red); }

.chart-box {
  width: 100%;
  height: 220px;
  border: 1px solid var(--hairline);
  border-radius: 8px;
  background: var(--panel);
  padding: 4px;
}
.chart-box-small { height: 130px; margin-top: 2px; }
.trading-svg { width: 100%; height: 100%; display: block; }

/* ============== RESPONSIVE ============== */
@media (max-width: 980px) {
  .stat-strip { grid-template-columns: repeat(3, 1fr); }
  .layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .log-row { grid-template-columns: 60px 50px 1fr; }
  .log-target { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse-dot.online { animation: none; }
  .progress-fill { transition: none; }
}
