/* ---------- palette (dataviz reference palette) ---------- */
:root {
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --border:         rgba(11,11,11,0.10);

  --series-blue:    #2a78d6;  /* facebook */
  --series-aqua:    #1baf7a;  /* instagram */

  --good:           #0ca30c;
  --warning:        #c98500;

  --floor:          #dedcd5;
  --floor-line:     rgba(0,0,0,0.05);
  --window-glass-1: #cfe4e6;
  --window-glass-2: #9fc3c9;
  --wood-wall:      #c9a56c;
  --wood-wall-dark: #a5824f;
  --office-kitchen: #d9d6a3;
  --office-kitchen-line: #c4c087;
  --office-rest:    #c3d0d6;
  --office-rest-line:#a9bac2;
  --room-wall:      #b9b6ac;

  --desk:           #d8bd93;
  --desk-dark:      #a9875c;
  --divider:        #e7ecec;
  --divider-frame:  #8b9598;
  --monitor:        #33383d;
  --monitor-screen: #4d90d9;
  --chair-seat:     #2f5fb0;
  --chair-back:     #23262b;

  --skin:           #e7b98c;
  --hair-1:         #2b2019;
  --hair-2:         #5b3a22;
  --hair-3:         #171512;
  --hair-4:         #a86b2e;
  --shirt-facebook: #2a78d6;
  --shirt-instagram:#1baf7a;
  --shirt-auditor:  #4a3aa7;
  --shoe:           #2b2b2b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --border:         rgba(255,255,255,0.10);
    --series-blue:    #3987e5;
    --series-aqua:    #199e70;
    --good:           #0ca30c;
    --warning:        #fab219;
  }
}

:root[data-theme="light"] {
  --surface-1: #fcfcfb; --page:#f9f9f7; --text-primary:#0b0b0b;
  --text-secondary:#52514e; --border: rgba(11,11,11,0.10);
  --series-blue:#2a78d6; --series-aqua:#1baf7a; --good:#0ca30c; --warning:#c98500;
}
:root[data-theme="dark"] {
  --surface-1:#1a1a19; --page:#0d0d0d; --text-primary:#ffffff;
  --text-secondary:#c3c2b7; --border: rgba(255,255,255,0.10);
  --series-blue:#3987e5; --series-aqua:#199e70; --good:#0ca30c; --warning:#fab219;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app {
  max-width: 1040px;
  margin: 24px auto;
  padding: 0 16px 40px;
}

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 14px;
}
.topbar__title {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}
.topbar__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 20%, transparent);
}
.topbar__source {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}
.theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  width: 30px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

/* ---------- office layout (top-down / bird's-eye) ---------- */
.office-wrap {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--floor);
}

.office {
  position: relative;
  height: 640px;
  overflow: hidden;
  background: var(--floor);
  background-image:
    repeating-linear-gradient(0deg, var(--floor-line) 0 1px, transparent 1px 64px),
    repeating-linear-gradient(90deg, var(--floor-line) 0 1px, transparent 1px 64px);
}

.floor, .props {
  position: absolute;
  inset: 0;
}

/* window wall along the top */
.window-band {
  position: absolute;
  top: 0; left: 0; right: 0; height: 64px;
  background: linear-gradient(180deg, var(--window-glass-2), var(--window-glass-1));
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.55) 0 4px, transparent 4px 118px),
    linear-gradient(180deg, var(--window-glass-2), var(--window-glass-1));
  border-bottom: 4px solid #8b93961a;
  box-shadow: 0 6px 14px rgba(0,0,0,0.12);
}

/* accent wood wall along the right edge */
.wood-wall {
  position: absolute;
  top: 64px; bottom: 0; right: 0; width: 60px;
  background: repeating-linear-gradient(115deg, var(--wood-wall) 0 14px, var(--wood-wall-dark) 14px 16px);
  box-shadow: inset 6px 0 10px rgba(0,0,0,0.12);
}

/* generic zone (kitchen / restroom) */
.zone {
  position: absolute;
  border-radius: 10px;
}
.zone--kitchen {
  background: var(--office-kitchen);
  border: 2px solid var(--office-kitchen-line);
}
.zone--restroom {
  background: var(--office-rest);
  border: 3px solid var(--room-wall);
}
.zone-label {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.6);
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
  pointer-events: none;
}

/* ---------- props (top-down sprites) ---------- */
.prop {
  position: absolute;
  transform: translate(-50%, -50%);
}

.plant2d {
  width: 46px; height: 46px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, #6dbb6f 0 40%, transparent 41%),
    radial-gradient(circle at 65% 35%, #4f9f57 0 42%, transparent 43%),
    radial-gradient(circle at 45% 65%, #3f8a4a 0 45%, transparent 46%),
    radial-gradient(circle at 50% 50%, #57a85d, #3a7d43);
}

.cafe-table {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: #cfc9bd;
  border: 2px solid #a8a196;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}
.cafe-chair {
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #2c2c2a;
  opacity: 0.85;
}

.desk2d {
  width: 148px; height: 62px;
  background: var(--desk);
  border: 2px solid var(--desk-dark);
  border-radius: 6px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.15);
}
.desk2d__monitor {
  position: absolute;
  width: 34px; height: 20px;
  left: 50%; transform: translateX(-50%);
  background: var(--monitor);
  border-radius: 3px;
}
.desk2d__monitor::after {
  content: "";
  position: absolute;
  inset: 2px;
  background: var(--monitor-screen);
  border-radius: 2px;
  opacity: 0.9;
}
.desk2d__keyboard {
  position: absolute;
  width: 26px; height: 10px;
  left: 50%; transform: translateX(-50%);
  background: #e9e6df;
  border: 1px solid #c3beb2;
  border-radius: 2px;
}
.divider2d {
  width: 148px; height: 12px;
  background: repeating-linear-gradient(90deg, var(--divider) 0 10px, #f4f6f6 10px 12px);
  border-top: 2px solid var(--divider-frame);
  border-bottom: 2px solid var(--divider-frame);
}

.chair2d {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--chair-back);
}
.chair2d::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: var(--chair-seat);
}

/* ---------- kitchen & restroom props ---------- */
.fridge2d {
  width: 34px; height: 40px;
  background: #eef1f2;
  border: 2px solid #b9c0c4;
  border-radius: 4px;
  position: relative;
}
.fridge2d::after {
  content: "";
  position: absolute;
  left: 4px; right: 4px; top: 15px;
  height: 2px;
  background: #b9c0c4;
}
.counter2d {
  width: 90px; height: 34px;
  background: #c9a06a;
  border: 2px solid #8a6a3e;
  border-radius: 4px;
}
.watercooler2d {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #cdeaff, #7fbfe8 70%);
  border: 2px solid #6ba9d6;
}
.printer2d {
  width: 44px; height: 34px;
  background: #6b7075;
  border: 2px solid #4d5155;
  border-radius: 4px;
}
.printer2d::after {
  content: "";
  position: absolute;
  left: 6px; right: 6px; bottom: 5px; height: 8px;
  background: #dfe1e2;
  border-radius: 1px;
}
.toilet2d {
  width: 24px; height: 30px;
  background: #fff;
  border: 2px solid #c9cdd0;
  border-radius: 40% 40% 60% 60% / 30% 30% 60% 60%;
}
.sink2d {
  width: 30px; height: 20px;
  background: #fff;
  border: 2px solid #c9cdd0;
  border-radius: 6px;
}

/* ---------- characters (top-down, with hair) ---------- */
.agent2d {
  position: absolute;
  width: 34px; height: 34px;
  transform: translate(-50%, -50%);
  transition: left 1s ease-in-out, top 1s ease-in-out;
  cursor: pointer;
  z-index: 500;
}
.agent2d--paused { opacity: 0.55; }

.agent2d__shoulders {
  position: absolute;
  bottom: 2px; left: 50%;
  width: 30px; height: 17px;
  border-radius: 10px 10px 5px 5px;
  transform: translateX(-50%);
}
.agent2d--facebook .agent2d__shoulders { background: var(--shirt-facebook); }
.agent2d--instagram .agent2d__shoulders { background: var(--shirt-instagram); }
.agent2d--auditor .agent2d__shoulders { background: var(--shirt-auditor); }

.agent2d__feet {
  position: absolute;
  bottom: -6px; left: 50%;
  width: 20px;
  display: flex;
  justify-content: space-between;
  transform: translateX(-50%);
}
.agent2d__foot {
  width: 7px; height: 9px;
  border-radius: 45% 45% 60% 60%;
  background: var(--shoe);
}
.agent2d__body.is-walking .agent2d__foot--l { animation: stepL 0.8s ease-in-out infinite; }
.agent2d__body.is-walking .agent2d__foot--r { animation: stepR 0.8s ease-in-out infinite; }
@keyframes stepL {
  0%, 100% { transform: translateY(-2px); }
  50% { transform: translateY(2px); }
}
@keyframes stepR {
  0%, 100% { transform: translateY(2px); }
  50% { transform: translateY(-2px); }
}

.agent2d__head {
  position: absolute;
  top: 0; left: 50%;
  width: 25px; height: 25px;
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: inset 0 -3px 4px rgba(0,0,0,0.15);
}
.agent2d__face {
  position: absolute;
  top: 6px; left: 50%;
  width: 13px; height: 12px;
  border-radius: 50%;
  background: var(--skin);
  transform: translateX(-50%);
}

.hair-1 { background: var(--hair-1); }
.hair-2 { background: var(--hair-2); }
.hair-3 { background: var(--hair-3); }
.hair-4 { background: var(--hair-4); }

.agent2d__body.is-sitting { animation: breathe 3s ease-in-out infinite; }
.agent2d--paused .agent2d__body.is-sitting { animation: none; }
.agent2d__body.is-walking { animation: waddle 0.8s ease-in-out infinite; }
.agent2d__body.is-idle-standing { animation: sipBob 1.4s ease-in-out infinite; }

.agent2d__body { position: relative; width: 100%; height: 100%; }

@keyframes breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}
@keyframes waddle {
  0%, 100% { transform: rotate(-4deg) translateY(0); }
  50% { transform: rotate(4deg) translateY(-1px); }
}
@keyframes sipBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(2px); }
}

.agent2d__tag {
  position: absolute;
  top: 100%; left: 50%;
  margin-top: 3px;
  transform: translateX(-50%);
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border-radius: 999px;
  pointer-events: none;
}

/* ---------- metrics side panel ---------- */
.metrics {
  position: absolute;
  top: 12px; right: 12px;
  background: rgba(10,10,14,0.72);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 150px;
  backdrop-filter: blur(4px);
}
.metrics__row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 11px;
  padding: 3px 0;
  font-variant-numeric: tabular-nums;
}
.metrics__label {
  color: #9a9a9a;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.metrics__label--good { color: var(--good); }
.metrics__label--warn { color: var(--warning); }
.metrics__value { color: #fff; font-weight: 600; }

/* ---------- status bar ---------- */
.statusbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 16px 16px;
  font-variant-numeric: tabular-nums;
}
.statusbar__pill {
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  color: var(--text-primary);
}
.statusbar__pill b { color: var(--good); }
.statusbar__sep {
  width: 1px; height: 14px;
  background: var(--border);
}

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10000;
}
.modal-backdrop.open { display: flex; }
.modal {
  position: relative;
  width: 100%;
  max-width: 460px;
  background: var(--surface-1);
  color: var(--text-primary);
  border-radius: 14px;
  border: 1px solid var(--border);
  padding: 22px;
  max-height: 86vh;
  overflow-y: auto;
}
.modal__close {
  position: absolute;
  top: 12px; right: 12px;
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.mdl-title { font-size: 16px; font-weight: 700; margin: 0 0 2px; padding-right: 24px; }
.mdl-sub { font-size: 12px; color: var(--text-secondary); margin: 0 0 16px; display:flex; align-items:center; gap:6px; }
.mdl-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
}
.mdl-badge--active { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.mdl-badge--paused { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.mdl-badge--platform-facebook { background: color-mix(in srgb, var(--series-blue) 16%, transparent); color: var(--series-blue); }
.mdl-badge--platform-instagram { background: color-mix(in srgb, var(--series-aqua) 16%, transparent); color: var(--series-aqua); }

.mdl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.mdl-stat {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}
.mdl-stat__label { font-size: 10px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.03em; }
.mdl-stat__value { font-size: 17px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.mdl-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 0 10px;
}
.mdl-back:hover { color: var(--text-primary); }

.mdl-camp-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mdl-camp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
}
.mdl-camp-row:hover { background: color-mix(in srgb, var(--series-blue) 6%, transparent); }
.mdl-camp-row__name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.mdl-camp-row__badges { display: flex; gap: 6px; }
.mdl-camp-row__spend { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }

.mdl-spark-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
