:root {
  --bg: #0b0e14;
  --panel: #121722;
  --panel-2: #161c28;
  --line: #222b3a;
  --text: #e6ebf4;
  --muted: #7b8798;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --ok: #3ecf8e;
  --bad: #ff5c72;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.02), 0 8px 24px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

/* The hidden attribute must beat class-based display rules. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 22px 40px;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand h1 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.2px;
  margin: 0;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.5);
  animation: pulse 2s infinite;
}
.dot.stale {
  background: var(--muted);
  animation: none;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(62, 207, 142, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(62, 207, 142, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(62, 207, 142, 0);
  }
}
.meta {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Cards */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.label {
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.muted {
  color: var(--muted);
}
.sep {
  margin: 0 7px;
  color: var(--line);
}
.ok {
  color: var(--ok);
}
.bad {
  color: var(--bad);
}

/* Admin */
.admin-tag {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(79, 140, 255, 0.35);
  letter-spacing: 0.6px;
}
.admin-card {
  padding: 16px 18px;
  margin-bottom: 16px;
  border-color: rgba(79, 140, 255, 0.35);
}
.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 8px;
  flex-wrap: wrap;
}
.admin-row input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
  padding: 9px 12px;
  width: 180px;
  font-variant-numeric: tabular-nums;
  outline: none;
}
.admin-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.admin-row button {
  background: var(--accent);
  color: #06122b;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 650;
  padding: 10px 16px;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.admin-row button:hover {
  filter: brightness(1.08);
}
.save-msg {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.admin-hint {
  font-size: 12.5px;
}
.admin-hint b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Campaign config */
.campaign-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}
.fld {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.fld > span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
}
.fld input {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.fld input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.btn-ghost {
  background: transparent !important;
  color: var(--text) !important;
  border: 1px solid var(--line) !important;
}
.btn-ghost:hover {
  border-color: var(--accent) !important;
}
.run-on {
  background: rgba(62, 207, 142, 0.16);
  color: var(--ok);
  border: 1px solid rgba(62, 207, 142, 0.35);
}
.run-off {
  background: rgba(123, 135, 152, 0.14);
  color: var(--muted);
  border: 1px solid var(--line);
}
@media (max-width: 700px) {
  .campaign-grid {
    grid-template-columns: 1fr 1fr;
  }
  .fld-wide {
    grid-column: 1 / -1;
  }
}

/* Goal */
.goal {
  padding: 20px 22px;
  margin-bottom: 16px;
}
.goal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.goal-nums {
  font-size: 30px;
  font-weight: 650;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.goal-nums .muted {
  font-size: 18px;
  font-weight: 500;
}
.goal-pct {
  font-size: 30px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.bar {
  height: 10px;
  background: var(--panel-2);
  border-radius: 999px;
  overflow: hidden;
  margin: 16px 0 10px;
  border: 1px solid var(--line);
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #7db0ff);
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.goal-foot {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  vertical-align: middle;
}
.badge.done {
  background: rgba(62, 207, 142, 0.16);
  color: var(--ok);
  border: 1px solid rgba(62, 207, 142, 0.35);
}
/* When the goal is reached, the bar + pct turn green. */
.is-complete .bar-fill {
  background: linear-gradient(90deg, var(--ok), #7ff0c0);
}
.is-complete .goal-pct {
  color: var(--ok);
}

/* KPIs */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}
.kpi {
  padding: 16px 18px;
}
.kpi .value {
  font-size: 28px;
  font-weight: 650;
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
}
.kpi .unit {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
  margin-left: 2px;
}
.kpi .sub {
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

/* Chart */
.chart-card {
  padding: 16px 18px 8px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
}
.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sw {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.sw.ok {
  background: var(--ok);
}
.sw.bad {
  background: var(--bad);
}
.chart-wrap {
  width: 100%;
  height: 240px;
}
#chart {
  width: 100%;
  height: 100%;
  display: block;
}

/* Split panels */
.split {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 14px;
}
.table-card {
  padding: 16px 18px;
  min-height: 260px;
}
.table-scroll {
  max-height: 320px;
  overflow-y: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 8px;
  position: sticky;
  top: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
tbody td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(34, 43, 58, 0.55);
  font-variant-numeric: tabular-nums;
}
.num {
  text-align: right;
}
.mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
  font-size: 12px;
}
.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.pill.on {
  background: rgba(62, 207, 142, 0.14);
  color: var(--ok);
}
.pill.off {
  background: rgba(123, 135, 152, 0.14);
  color: var(--muted);
}

/* Feed */
.feed {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.feed-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 6px;
  border-bottom: 1px solid rgba(34, 43, 58, 0.45);
  font-size: 12.5px;
}
.feed-row .t {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  width: 62px;
  flex: none;
}
.feed-row .st {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.tick {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}
.tick.ok {
  background: var(--ok);
}
.tick.bad {
  background: var(--bad);
}

.foot {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 8px;
}

/* Responsive */
@media (max-width: 820px) {
  .kpis {
    grid-template-columns: repeat(2, 1fr);
  }
  .split {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 460px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}
