/* AgentLeash — control plane for autonomous AI shopping agents */

:root {
  --bg: #060606;
  --surface: rgba(24, 24, 27, 0.55);
  --surface-solid: #141417;
  --surface-hover: rgba(24, 24, 27, 0.85);
  --border: rgba(63, 63, 70, 0.55);
  --border-strong: #52525b;
  --fg: #f4f4f5;
  --fg-dim: #a1a1aa;
  --fg-faint: #71717a;
  --accent: #38bdf8;
  --good: #34d399;
  --hold: #fbbf24;
  --block: #fb7185;
  --radius: 14px;
  --shadow: 0 12px 40px -18px rgba(0, 0, 0, 0.85);
  font-synthesis: none;
}

* { box-sizing: border-box; }

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

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.85rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: rgba(6, 6, 6, 0.9);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 0.6rem; }
.brand-glyph {
  width: 22px; height: 22px; border-radius: 7px;
  background: conic-gradient(from 140deg, var(--accent), var(--good), var(--accent));
  box-shadow: 0 0 16px -2px var(--accent);
  position: relative;
}
.brand-glyph::after {
  content: ""; position: absolute; inset: 6px;
  border-radius: 3px; background: var(--bg);
}
.brand-name { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.topbar-meta { display: flex; align-items: center; gap: 1rem; font-size: 0.82rem; color: var(--fg-dim); flex-wrap: wrap; }
.household { color: var(--fg); font-weight: 600; }
.snapshot strong { color: var(--fg); }
.status-pill {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em;
  padding: 0.2rem 0.55rem; border: 1px solid var(--border-strong);
  border-radius: 999px; color: var(--fg-dim);
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1.1rem;
  padding: 1.1rem;
  max-width: 1500px;
  margin: 0 auto;
}
@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Rail ---------- */
.rail { display: flex; flex-direction: column; gap: 1.1rem; }
.rail-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 1.15rem;
}
.rail-header h2 { font-size: 0.95rem; }
.rail-sub { margin: 0.25rem 0 0.85rem; font-size: 0.76rem; color: var(--fg-faint); }

.agent-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.55rem; }
.agent-item {
  display: flex; align-items: flex-start; gap: 0.7rem;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(9, 9, 11, 0.5);
  transition: border-color 0.15s, opacity 0.15s;
}
.agent-item.off { opacity: 0.5; }
.agent-glyph {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 0.95rem; font-weight: 700;
  color: #0a0a0a;
}
.agent-main { flex: 1 1 auto; min-width: 0; }
.agent-name { font-size: 0.84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-platform { font-size: 0.68rem; color: var(--fg-faint); }
.agent-scope { font-size: 0.71rem; color: var(--fg-dim); margin-top: 0.2rem; }
.agent-toggle {
  flex: 0 0 auto; appearance: none; -webkit-appearance: none;
  width: 38px; height: 22px; border-radius: 999px;
  background: #3f3f46; border: none; cursor: pointer; position: relative;
  transition: background 0.15s; margin-top: 2px;
}
.agent-toggle::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 16px; height: 16px; border-radius: 50%; background: #e4e4e7;
  transition: transform 0.15s;
}
.agent-toggle[aria-pressed="true"] { background: var(--good); }
.agent-toggle[aria-pressed="true"]::after { transform: translateX(16px); }

/* ---------- Controls ---------- */
.control { margin-bottom: 1rem; }
.control > label, .control-label { display: block; font-size: 0.78rem; color: var(--fg-dim); margin-bottom: 0.4rem; }
.control-row { display: flex; align-items: center; gap: 0.7rem; }
.control-out { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.9rem; min-width: 56px; text-align: right; color: var(--fg); }

input[type="range"] {
  flex: 1 1 auto; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 999px; background: #3f3f46; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); cursor: pointer;
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.18);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: var(--accent); cursor: pointer;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  font-size: 0.73rem; padding: 0.28rem 0.6rem; border-radius: 999px;
  border: 1px solid var(--border-strong); background: rgba(9, 9, 11, 0.5);
  color: var(--fg-dim); cursor: pointer; transition: all 0.12s; user-select: none;
}
.chip.on {
  background: rgba(251, 113, 133, 0.15);
  border-color: var(--block); color: #fecdd3;
}
.chip::before { content: "+ "; opacity: 0.6; }
.chip.on::before { content: "✕ "; opacity: 0.9; }

.toggles { display: flex; flex-direction: column; gap: 0.6rem; }
.switch-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.79rem; color: var(--fg-dim); cursor: pointer; }
.switch-row input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.switch-row strong { color: var(--fg); }

.rail-footer { margin-top: 0.5rem; }
.footnote { font-size: 0.71rem; color: var(--fg-faint); margin: 0; }

/* ---------- Board ---------- */
.board { display: flex; flex-direction: column; gap: 1.1rem; min-width: 0; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.85rem 0.95rem;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.kpi-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--fg-faint); }
.kpi-value { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.kpi-sub { font-size: 0.74rem; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.kpi-hold .kpi-value { color: var(--hold); }
.kpi-block .kpi-value { color: var(--block); }
.kpi-bar-wrap { display: block; height: 9px; border-radius: 999px; background: #27272a; overflow: hidden; margin: 0.5rem 0 0.3rem; }
.kpi-bar { display: block; height: 100%; width: 0%; border-radius: 999px; background: linear-gradient(90deg, var(--good), var(--accent)); transition: width 0.35s ease, background 0.35s; }
.kpi-bar.warn { background: linear-gradient(90deg, var(--hold), var(--block)); }
.kpi-bar.over { background: var(--block); }

/* ---------- Panels ---------- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.1rem; }
@media (max-width: 920px) { .grid { grid-template-columns: 1fr; } }
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem 1.15rem; min-width: 0;
}
.panel-wide { grid-column: 1 / -1; }
.panel > header { display: flex; flex-direction: column; gap: 0.15rem; margin-bottom: 0.85rem; }
.panel > header h3 { font-size: 0.98rem; }
.panel-sub { font-size: 0.76rem; color: var(--fg-faint); }

/* ---------- Queue ---------- */
.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.queue-item {
  display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap;
  padding: 0.75rem 0.85rem; border: 1px solid rgba(251, 191, 36, 0.35);
  border-left: 3px solid var(--hold);
  border-radius: 11px; background: rgba(251, 191, 36, 0.06);
}
.q-glyph { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; color: #0a0a0a; flex: 0 0 auto; }
.q-main { flex: 1 1 220px; min-width: 0; }
.q-item-name { font-size: 0.85rem; font-weight: 600; }
.q-meta { font-size: 0.73rem; color: var(--fg-dim); }
.q-reason { font-size: 0.72rem; color: var(--hold); margin-top: 0.15rem; }
.q-amount { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 0.95rem; flex: 0 0 auto; }
.q-actions { display: flex; gap: 0.4rem; flex: 0 0 auto; }
.q-actions button {
  font-size: 0.76rem; font-weight: 600; padding: 0.38rem 0.7rem;
  border-radius: 8px; cursor: pointer; border: 1px solid var(--border-strong);
  background: transparent; color: var(--fg);
}
.q-approve { border-color: var(--good) !important; color: var(--good) !important; }
.q-approve:hover { background: rgba(52, 211, 153, 0.12); }
.q-deny:hover { background: rgba(251, 113, 133, 0.12); }
.empty-note { font-size: 0.8rem; color: var(--fg-faint); margin: 0.3rem 0 0; }

/* ---------- Feed ---------- */
.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.feed-item {
  display: grid;
  grid-template-columns: 56px 1fr auto auto;
  align-items: center; gap: 0.75rem;
  padding: 0.7rem 0.2rem; border-bottom: 1px solid var(--border);
}
.feed-item:last-child { border-bottom: none; }
.f-time { font-size: 0.72rem; color: var(--fg-faint); font-variant-numeric: tabular-nums; }
.f-body { min-width: 0; }
.f-line1 { display: flex; align-items: center; gap: 0.45rem; font-size: 0.85rem; }
.f-agentdot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.f-merchant { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-item { color: var(--fg-dim); font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f-reason { font-size: 0.72rem; color: var(--fg-faint); margin-top: 0.12rem; }
.f-amount { font-weight: 650; font-variant-numeric: tabular-nums; font-size: 0.9rem; text-align: right; }
.verdict {
  font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.22rem 0.55rem; border-radius: 999px; white-space: nowrap;
}
.verdict-approved { background: rgba(52, 211, 153, 0.14); color: var(--good); }
.verdict-held { background: rgba(251, 191, 36, 0.14); color: var(--hold); }
.verdict-blocked { background: rgba(251, 113, 133, 0.14); color: var(--block); }
.feed-item.is-blocked .f-amount, .feed-item.is-blocked .f-merchant { text-decoration: line-through; text-decoration-color: var(--fg-faint); }
@media (max-width: 560px) {
  .feed-item { grid-template-columns: 1fr auto; }
  .f-time { display: none; }
}

/* ---------- Spend by agent ---------- */
.agentspend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; }
.as-item { display: flex; flex-direction: column; gap: 0.3rem; }
.as-top { display: flex; justify-content: space-between; font-size: 0.82rem; }
.as-name { display: flex; align-items: center; gap: 0.45rem; }
.as-dot { width: 9px; height: 9px; border-radius: 50%; }
.as-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.as-bar-wrap { height: 6px; border-radius: 999px; background: #27272a; overflow: hidden; }
.as-bar { height: 100%; border-radius: 999px; transition: width 0.35s; }

/* ---------- Audit export ---------- */
.plan-actions { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.75rem; flex-wrap: wrap; }
.plan-actions button {
  font-size: 0.8rem; font-weight: 600; padding: 0.45rem 0.85rem;
  border-radius: 9px; cursor: pointer; border: 1px solid var(--accent);
  background: rgba(56, 189, 248, 0.12); color: var(--accent);
}
.plan-actions button.secondary { border-color: var(--border-strong); background: transparent; color: var(--fg-dim); }
.plan-actions button:hover { filter: brightness(1.15); }
.copy-status { font-size: 0.75rem; color: var(--good); }
.plan-text {
  margin: 0; max-height: 320px; overflow: auto;
  background: #0a0a0b; border: 1px solid var(--border); border-radius: 10px;
  padding: 0.85rem; font-size: 0.74rem; line-height: 1.5;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color: var(--fg-dim); white-space: pre-wrap; word-break: break-word;
}

/* ---------- Bottombar ---------- */
.bottombar {
  padding: 1rem 1.4rem; border-top: 1px solid var(--border);
  font-size: 0.74rem; color: var(--fg-faint); text-align: center;
}
