:root {
  --bg: #0a0a0f;
  --bg-soft: #14141d;
  --card: #16161f;
  --card-hi: #1d1d29;
  --line: #262633;
  --text: #f4f4f7;
  --muted: #9a9ab0;
  --fuchsia: #e0218a;
  --fuchsia-soft: rgba(224, 33, 138, 0.16);
  --green: #2fd47a;
  --amber: #f0b53e;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #1a1226 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topwrap {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 14px) 18px 10px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tab.active { background: var(--fuchsia-soft); border-color: var(--fuchsia); color: var(--text); }
.tab-badge {
  background: var(--fuchsia);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 { font-size: 1.12rem; margin: 0; letter-spacing: 0.3px; font-weight: 700; }

.logo {
  width: 26px; height: 26px; border-radius: 8px;
  background: radial-gradient(circle at 50% 50%, var(--fuchsia) 0 30%, transparent 32%),
              conic-gradient(from 0deg, transparent 0 75%, var(--fuchsia) 75% 100%);
  border: 1.5px solid var(--fuchsia);
  box-shadow: 0 0 16px var(--fuchsia-soft);
}

.btn {
  appearance: none;
  border: 1px solid var(--fuchsia);
  background: var(--fuchsia-soft);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.2s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.96); }
.btn:disabled { opacity: 0.5; cursor: default; border-color: var(--line); background: var(--card); }
.btn.on { background: rgba(47, 212, 122, 0.14); border-color: var(--green); }
.btn.small { padding: 7px 13px; font-size: 0.82rem; }

.settings {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.set-label { font-size: 0.9rem; color: var(--text); }
.set-control { display: flex; align-items: center; gap: 7px; }
.set-minus { color: var(--fuchsia); font-weight: 700; font-size: 1.05rem; }
#minDisc {
  width: 58px;
  background: #0f0f17;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 9px;
  padding: 8px;
  font-size: 1rem;
  text-align: center;
}
#minDisc:focus { outline: none; border-color: var(--fuchsia); }
.set-pct { color: var(--muted); font-size: 0.86rem; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.notifs-card { margin-top: 12px; }
.notifs-title { font-size: 0.9rem; font-weight: 700; margin-bottom: 6px; }
.notif-agent { padding: 8px 0; border-top: 1px solid var(--line); }
.notif-agent:first-child { border-top: none; }
.notif-agent-name { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin: 4px 0 2px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; font-size: 0.9rem; cursor: pointer; }
.switch {
  appearance: none; -webkit-appearance: none;
  width: 44px; height: 25px; flex: none;
  background: #2a2a38; border-radius: 999px; position: relative; cursor: pointer;
  transition: background 0.2s;
}
.switch:checked { background: var(--fuchsia); }
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 21px; height: 21px; border-radius: 50%; background: #fff;
  transition: transform 0.2s;
}
.switch:checked::after { transform: translateX(19px); }

.notif-help { margin: 4px 0 14px; line-height: 1.45; }
.ch-label { flex: 1 1 auto; min-width: 0; }
.ch-ctrl { display: flex; align-items: center; gap: 8px; flex: none; }
.thr {
  width: 66px;
  background: #0f0f17;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.92rem;
  text-align: center;
}
.thr:focus { outline: none; border-color: var(--fuchsia); }
.thr-pct { color: var(--muted); font-size: 0.85rem; margin-left: -4px; }

main { max-width: 760px; margin: 0 auto; padding: 18px 16px 60px; }

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin: 26px 4px 12px;
  font-weight: 700;
}
.section-title:first-child { margin-top: 6px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.card {
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.card.empty { color: var(--muted); font-size: 0.9rem; text-align: center; padding: 22px; }

.agent .agent-head { display: flex; align-items: center; gap: 9px; font-size: 1rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); flex: none; }
.agent.warn .status-dot { background: var(--amber); box-shadow: 0 0 10px var(--amber); }
.agent .agent-msg { color: var(--muted); font-size: 0.86rem; margin-top: 8px; line-height: 1.4; }
.agent .agent-foot { color: #6d6d82; font-size: 0.74rem; margin-top: 10px; }

/* agents that report a live price board take the full row */
.agent.has-board { grid-column: 1 / -1; }

.board { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.board-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  background: #0f0f17;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.board-row.is-deal { border-color: var(--fuchsia); box-shadow: 0 0 0 1px var(--fuchsia-soft); }
.b-label { flex: 1 1 auto; font-size: 0.86rem; min-width: 0; }
.b-prices {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  white-space: nowrap;
}
.b-main { font-size: 0.92rem; }
.b-main b { color: var(--text); }
.b-main.muted { color: var(--muted); font-weight: 600; }
.b-tc { color: var(--muted); font-size: 0.68rem; font-weight: 400; }
.b-sub { color: #6d6d82; font-size: 0.72rem; }
.b-badge {
  flex: 0 0 auto;
  min-width: 52px;
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 999px;
}
.b-badge.deal { background: var(--fuchsia); color: #fff; }
.b-badge.cheap { background: rgba(47, 212, 122, 0.16); color: var(--green); }
.b-badge.over { background: #1d1d29; color: var(--muted); }
.b-badge.na { background: #1d1d29; color: #6d6d82; }

.feed { display: flex; flex-direction: column; gap: 10px; }

.finding {
  display: block;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(180deg, var(--card-hi), var(--card));
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  border-radius: 12px;
  padding: 13px 15px;
  transition: border-color 0.2s ease, transform 0.08s ease;
}
.finding[href]:active { transform: scale(0.99); }
.finding.alert { border-left-color: var(--fuchsia); box-shadow: 0 0 0 1px var(--fuchsia-soft); }
.finding-title { font-weight: 650; font-size: 0.98rem; }
.finding-body { color: var(--muted); font-size: 0.86rem; margin-top: 5px; line-height: 1.45; }
.finding-foot { color: #6d6d82; font-size: 0.73rem; margin-top: 9px; text-transform: capitalize; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 22px);
  transform: translateX(-50%) translateY(20px);
  background: var(--card-hi);
  border: 1px solid var(--fuchsia);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
