:root {
  color-scheme: dark;
  --bg: #050505;
  --panel: #111113;
  --panel-2: #17171a;
  --line: rgba(255, 255, 255, 0.08);
  --muted: #8f8f96;
  --text: #f4f4f5;
  --cyan: #34d399;
  --green: #34d399;
  --violet: #9a9aa2;
  --amber: #eab308;
  --red: #f87171;
  --blue: #60a5fa;
  --pink: #f472b6;
  --c-needs-review: var(--amber);
  --c-reviewed-vuln: var(--red);
  --c-reviewed-safe: var(--blue);
  --c-verified-poc: var(--green);
  --c-verified-nopoc: var(--violet);
  --c-clean: var(--blue);
  --c-issue: var(--red);
  --c-partial: var(--amber);
  --c-skip: var(--muted);
  --accent-1: var(--cyan);
  --accent-2: var(--violet);
  --accent-3: var(--green);
  --accent-4: var(--amber);
  --accent-5: var(--blue);
  --accent-6: var(--pink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* { box-sizing: border-box; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon use[href="#icon-zap"] { fill: currentColor; stroke: none; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 72% 0%, rgba(64, 92, 166, 0.13), transparent 28rem),
    var(--bg);
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; }

.topbar {
  height: 72px;
  padding: 0 clamp(20px, 4vw, 64px);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  width: fit-content;
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  padding: 9px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: var(--panel-2);
}

.brand-mark i {
  width: 4px;
  background: var(--cyan);
  box-shadow: 0 0 9px rgba(84, 220, 255, 0.65);
}
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 19px; }
.brand-mark i:nth-child(3) { height: 14px; }
.brand strong { display: block; font-size: 14px; letter-spacing: 0.16em; }
.brand small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; letter-spacing: 0.3em; }

.view-switcher {
  display: flex;
  padding: 4px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.view-button {
  border: 0;
  border-radius: 9px;
  padding: 8px 16px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.view-button span { margin-right: 5px; }
.view-button:hover { color: var(--text); }
.view-button.active {
  color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 16%, transparent);
}

.connection {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}
.connection time { color: #536079; }
.logout-button {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.logout-button:hover { color: var(--text); border-color: color-mix(in srgb, var(--text) 30%, var(--line)); }
.pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(255, 199, 102, 0.08);
}
.connection.online .pulse { background: var(--green); box-shadow: 0 0 0 5px rgba(81, 230, 165, 0.08); }
.connection.offline .pulse { background: var(--red); }

main { padding: 0 clamp(20px, 4vw, 64px) 48px; }

.view-panel { display: none; }
.view-panel.active { display: block; }

.village-toolbar, .dash-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 30px 2px 20px;
}
.eyebrow { color: var(--muted) !important; font-size: 9px !important; letter-spacing: 0.22em; font-weight: 800; }
.village-toolbar h1 { font-size: 24px; margin: 4px 0 5px; letter-spacing: -0.03em; }
.dash-heading h1 { font-size: 30px; margin: 4px 0 5px; font-weight: 800; letter-spacing: -0.02em; }
.village-toolbar p, .dash-heading p { color: var(--muted); font-size: 12px; margin: 0; }

.map-legend { display: flex; gap: 17px; color: var(--muted); font-size: 10px; }
.map-legend span { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; }
.legend-dot.running { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.legend-dot.warning { background: var(--amber); }
.legend-dot.verified { background: var(--green); }

.village-frame {
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--panel);
}

/* The stage keeps the map's own pixel coordinate space and is scaled as a
   whole, so sprites, bubbles and tiles always line up. The size comes from
   village-map.json via --map-width/--map-height; the defaults are the
   dimensions of the art currently in static/images. */
.village-viewport {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  background: #63c74d;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.village-viewport::-webkit-scrollbar { display: none; }
.village-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--map-width, 1280px);
  height: var(--map-height, 720px);
  transform-origin: 0 0;
  transform: scale(var(--map-scale, 1));
}
.village-map-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.agent-layer { position: absolute; inset: 0; }
.agent {
  --facing: 1;
  --x: 0px;
  --y: 0px;
  position: absolute;
  left: 0;
  top: 0;
  width: 48px;
  height: 58px;
  margin-left: -24px;
  margin-top: -58px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: translate3d(var(--x), var(--y), 0);
  transition: transform var(--step-ms, 320ms) linear;
}
.agent:focus-visible { outline: none; }
.agent-shadow {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 22px;
  height: 6px;
  margin-left: -11px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.26);
}
/* The sprite sheets are cut with the feet 5px above the canvas bottom, so the
   frame hangs that far below the tile line to stand the character on it. */
.agent-sprite {
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translateX(-50%) scaleX(var(--facing));
}
.agent-img {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.agent.walking .agent-sprite { animation: agent-step 0.34s steps(2) infinite; }
@keyframes agent-step { 0%, 100% { translate: 0 0; } 50% { translate: 0 -1px; } }

/* Name tag in the style of the reference town: small white pixel bubble. */
.agent-tag, .miner-tag {
  position: absolute;
  left: 50%;
  bottom: calc(100% - 6px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border: 1px solid #2b2f38;
  border-radius: 3px;
  background: #ffffff;
  color: #23262d;
  font-size: 9px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.01em;
  white-space: nowrap;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.agent-tag::after, .miner-tag::after {
  content: "";
  position: absolute;
  left: 8px;
  top: 100%;
  border: 3px solid transparent;
  border-top-color: #ffffff;
}
.agent-tag b, .miner-tag b { font-weight: 800; }
.agent-tag i, .miner-tag i { font-style: normal; }
.agent:hover .agent-tag, .agent:focus-visible .agent-tag,
.miner:hover .miner-tag, .miner:focus-visible .miner-tag { background: #fdf7c3; }
.agent-alert, .miner-alert {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 12px);
  margin-left: 12px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--amber);
  color: #1c2332;
  font-size: 9px;
  line-height: 15px;
  font-weight: 900;
  text-align: center;
}

.empty-village {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: #22301f;
  background: rgba(255, 255, 255, 0.72);
}
.empty-village[hidden] { display: none; }
.empty-village span { font-size: 30px; }
.empty-village strong { margin-top: 9px; }
.empty-village p { font-size: 12px; }
.map-footer {
  height: 35px;
  padding: 0 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 9px;
  letter-spacing: 0.1em;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------------ mine ---
   The shaft is one stacked column of 1280px strips, so it keeps the art's own
   pixel coordinate space and is scaled as a whole, exactly like the village.
   Every offset below comes from static/mine.json through a custom property:
   --mine-floor/--mine-slab size a floor, --miner-x/--face-x/--sign-x/--cart-x
   place things on it. Nothing here hardcodes the art except as a fallback. */
.mine-viewport {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  background: #0a0806;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.mine-viewport::-webkit-scrollbar { display: none; }
.mine-stage {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--mine-width, 1280px);
  height: var(--mine-height, 316px);
  transform-origin: 0 0;
  transform: scale(var(--mine-scale, 1));
}
.mine-surface {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--mine-width, 1280px);
  height: var(--mine-surface, 140px);
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.mine-floors { position: absolute; inset: 0; }
.mine-floor {
  position: absolute;
  left: 0;
  top: var(--floor-top, 0px);
  width: var(--mine-width, 1280px);
  height: var(--mine-floor, 176px);
}
/* Only the rock is dimmed with depth -- dimming the miner too would make the
   deepest floors unreadable. */
.mine-strip {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: brightness(var(--dim, 1));
}

.mine-lamp { position: absolute; left: var(--lamp-x, 660px); top: var(--lamp-y, 50px); }
.mine-lamp::after {
  content: "";
  position: absolute;
  left: -105px;
  top: -105px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 198, 112, 0.3), rgba(255, 168, 66, 0.09) 46%, transparent 70%);
  animation: lamp-flicker 3.1s ease-in-out infinite;
}
@keyframes lamp-flicker {
  0%, 100% { opacity: 0.5; }
  22% { opacity: 0.95; }
  40% { opacity: 0.62; }
  58% { opacity: 1; }
  76% { opacity: 0.7; }
}

/* Level plate nailed to the ceiling next to the ladder. */
.mine-sign {
  position: absolute;
  left: var(--sign-x, 208px);
  top: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 8px 4px;
  border: 1px solid #2b1d10;
  border-radius: 2px;
  background: linear-gradient(#a9743c, #7a4e28);
  color: #ffe9c2;
  font-size: 9px;
  line-height: 1.3;
  white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.mine-sign::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 1px;
  height: 20px;
  background: #6d5231;
}
.mine-sign b { font-weight: 900; letter-spacing: 0.06em; }
.mine-sign small {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: rgba(255, 233, 194, 0.72);
  font-size: 8px;
}

/* Gems the frontend embeds in the dig face: a diamond once a project has a
   verified PoC, plain ore otherwise. */
.mine-vein {
  position: absolute;
  left: var(--face-x, 1128px);
  bottom: var(--mine-slab, 60px);
  width: 130px;
  height: 96px;
}
.mine-vein img {
  position: absolute;
  width: 14px;
  height: 14px;
  image-rendering: pixelated;
  animation: gem-twinkle 2.6s ease-in-out infinite;
}
.mine-vein img.gem { filter: drop-shadow(0 0 6px rgba(126, 224, 255, 0.5)); }
.mine-vein img:nth-child(1) { left: 16px; bottom: 54px; }
.mine-vein img:nth-child(2) { left: 46px; bottom: 74px; animation-delay: 0.7s; }
.mine-vein img:nth-child(3) { left: 32px; bottom: 22px; animation-delay: 1.4s; }
@keyframes gem-twinkle { 0%, 100% { opacity: 0.72; } 50% { opacity: 1; } }

/* What this floor has hauled out, floating over the ore cart. */
.mine-haul {
  position: absolute;
  /* Centred over the cart, which is ~68px wide in the art. */
  left: calc(var(--cart-x, 232px) + 34px);
  bottom: calc(var(--mine-slab, 60px) + 44px);
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border: 1px solid #2b2f38;
  border-radius: 3px;
  background: #ffffff;
  color: #23262d;
  font-size: 9px;
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.mine-haul[hidden] { display: none; }
.mine-haul img { width: 11px; height: 11px; image-rendering: pixelated; }

.miner {
  --swing: 0.92s;
  position: absolute;
  left: var(--miner-x, 1056px);
  bottom: var(--mine-slab, 60px);
  width: 48px;
  height: 58px;
  margin-left: -24px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.miner:focus-visible { outline: none; }
/* Review badge sits left of the head: the name tag is centred above it and the
   pickaxe swings through the right. */
.miner-alert {
  left: auto;
  right: calc(50% + 16px);
  bottom: 26px;
  margin-left: 0;
}
.miner-shadow {
  position: absolute;
  left: 50%;
  bottom: -3px;
  width: 22px;
  height: 6px;
  margin-left: -11px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
}
.miner-sprite { position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%); }
/* The sprite carries the positioning transform, so the swing bob uses the
   separate translate property and the two never overwrite each other. */
.miner-img {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  animation: miner-bob var(--swing) ease-in-out infinite var(--swing-delay, 0s);
}
@keyframes miner-bob { 0%, 100% { translate: 0 0; } 54% { translate: 0 1px; } }

.miner-hand { position: absolute; inset: 0; }
/* Placed so the rotation origin lands on the character's hands: the pickaxe art
   is 32px with its grip butt at (8, 27), hence the origin and the offsets. */
.miner-arm {
  position: absolute;
  left: 20px;
  bottom: 19px;
  width: 32px;
  height: 32px;
  transform-origin: 25% 84%;
  animation: pick-swing var(--swing) cubic-bezier(0.3, 0, 0.35, 1) infinite var(--swing-delay, 0s);
}
.miner-pick { display: block; width: 32px; height: 32px; image-rendering: pixelated; }
/* The art points up-right at rest, so winding up over the shoulder is a negative
   rotation and the strike down into the rock face is a positive one. */
@keyframes pick-swing {
  0% { transform: rotate(-50deg); }
  36% { transform: rotate(-64deg); }
  54% { transform: rotate(72deg); }
  62% { transform: rotate(62deg); }
  100% { transform: rotate(-50deg); }
}

/* Where the head lands on the strike frame. */
.miner-sparks { position: absolute; left: 52px; bottom: 15px; width: 1px; height: 1px; }
.miner-sparks i {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #ffe9a8;
  box-shadow: 0 0 4px rgba(255, 214, 120, 0.9);
  opacity: 0;
  animation: spark-fly var(--swing) linear infinite var(--swing-delay, 0s);
}
/* Each spark trails the one before it, on top of whatever offset the floor has. */
.miner-sparks i:nth-child(1) { --sx: 13px; --sy: -15px; }
.miner-sparks i:nth-child(2) { --sx: 6px; --sy: -20px; animation-delay: calc(var(--swing-delay, 0s) + 0.04s); }
.miner-sparks i:nth-child(3) { --sx: 15px; --sy: -5px; animation-delay: calc(var(--swing-delay, 0s) + 0.08s); }
@keyframes spark-fly {
  0%, 50% { opacity: 0; translate: 0 0; }
  56% { opacity: 1; translate: calc(var(--sx) * 0.3) calc(var(--sy) * 0.35); }
  90% { opacity: 0; translate: var(--sx) var(--sy); }
  100% { opacity: 0; translate: 0 0; }
}

.empty-mine {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  color: #f0e6d6;
  background: rgba(9, 7, 5, 0.84);
}
.empty-mine[hidden] { display: none; }
.empty-mine span { font-size: 30px; }
.empty-mine strong { margin-top: 9px; }
.empty-mine p { color: var(--muted); font-size: 12px; }

@media (prefers-reduced-motion: reduce) {
  .miner-img, .miner-arm, .miner-sparks i, .mine-lamp::after, .mine-vein img { animation: none; }
}

.dash-heading { align-items: center; }
.search-box { width: min(340px, 40vw); display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 0 12px; color: var(--muted); }
.search-box input { width: 100%; height: 39px; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.table-wrap { border: 1px solid var(--line); border-radius: 16px; overflow: auto; background: var(--panel); }
table { width: 100%; min-width: 850px; border-collapse: collapse; }
th { color: var(--muted); font-size: 9px; letter-spacing: .1em; font-weight: 700; text-align: left; padding: 14px 17px; border-bottom: 1px solid var(--line); }
td { padding: 15px 17px; font-size: 12px; border-bottom: 1px solid rgba(142, 170, 215, .08); }
tbody tr { cursor: pointer; transition: background .15s; }
tbody tr:hover { background: rgba(84, 220, 255, .035); }
tbody tr:last-child td { border-bottom: 0; }
.project-cell strong, .project-cell small { display: block; }
.project-cell small { color: var(--muted); font-size: 10px; margin-top: 4px; }
.table-status, .status-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 4px; padding: 5px 8px; font-size: 8px; letter-spacing: .1em; font-weight: 800; }
.table-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.table-status.running, .status-pill.running { color: var(--green); background: rgba(81, 230, 165, .1); }
.table-status.stopped, .status-pill.stopped { color: var(--muted); background: rgba(129, 144, 170, .1); }
.table-status.stale, .status-pill.stale { color: var(--amber); background: rgba(255, 199, 102, .1); }
.number-cell { font-variant-numeric: tabular-nums; font-weight: 700; }
.number-cell.review { color: var(--amber); }
.number-cell.poc { color: var(--green); }
.number-cell.clean { color: var(--blue); }
.empty-table { padding: 50px; text-align: center; color: var(--muted); }
.empty-inline { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 12px; }

html { scroll-behavior: smooth; }

.dash-shell { display: grid; grid-template-columns: 208px 1fr; gap: 24px; align-items: start; }

.dash-rail {
  position: sticky;
  top: 90px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 16px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}
.rail-title { color: var(--muted); font-size: 9px; letter-spacing: 0.16em; font-weight: 800; margin: 12px 6px 6px; }
.rail-title:first-child { margin-top: 2px; }
.rail-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 7px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.rail-link:hover { color: var(--text); background: rgba(84, 220, 255, 0.08); }
.rail-meta { padding: 2px 6px 10px; }
.rail-meta strong { display: block; font-size: 16px; font-variant-numeric: tabular-nums; }

.dash-main { min-width: 0; }

.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: 20px 22px;
  scroll-margin-top: 90px;
}
.pipeline-panel { margin-bottom: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 11px; letter-spacing: 0.14em; color: var(--text); font-weight: 800; }
.panel-head span { color: var(--muted); font-size: 9px; letter-spacing: 0.08em; font-variant-numeric: tabular-nums; }

.pipeline-flow { display: flex; align-items: stretch; gap: 4px; overflow-x: auto; padding-bottom: 6px; }
.pipeline-stage {
  --stage-color: var(--cyan);
  flex: 1 0 108px;
  min-width: 108px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-2);
}
.pipeline-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: var(--stage-color);
  background: color-mix(in srgb, var(--stage-color) 14%, transparent);
}
.pipeline-stage strong { font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1; }
.pipeline-stage small { color: var(--muted); font-size: 8.5px; letter-spacing: 0.06em; text-align: center; text-transform: uppercase; }
.pipeline-chevron { flex: 0 0 auto; display: flex; align-items: center; color: var(--muted); opacity: 0.55; }
.pipeline-bar { display: flex; height: 6px; border-radius: 4px; overflow: hidden; background: rgba(129, 144, 170, 0.13); margin-top: 4px; gap: 1px; }
.pipeline-bar i { display: block; height: 100%; }

.dash-columns { display: grid; grid-template-columns: 1fr 336px; gap: 20px; align-items: start; margin-top: 20px; }
.dash-col-main, .dash-col-side { display: flex; flex-direction: column; gap: 20px; min-width: 0; }

.active-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.active-card {
  --accent: var(--cyan);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.active-card:hover, .active-card:focus-visible { transform: translateY(-2px); outline: none; border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.active-card-top { display: flex; align-items: center; gap: 10px; }
.active-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%;
  font-size: 13px;
  font-weight: 800;
  color: #06140f;
  background: linear-gradient(145deg, var(--accent), color-mix(in srgb, var(--accent) 55%, white 10%));
}
.active-card-name { min-width: 0; flex: 1; }
.active-card-name strong { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-card-name small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-card-top .agent-alert { position: static; margin-left: 0; flex-shrink: 0; }
.active-card-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.active-card-progress { display: block; }
.active-card-progress .bar-track { display: block; }
.active-card-progress small { display: block; margin-top: 5px; color: var(--muted); font-size: 8.5px; letter-spacing: 0.06em; }
.active-card-progress.muted { padding-top: 2px; }

.node-list { display: grid; gap: 10px; }
.node-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); }
.node-row.offline { border-color: rgba(248, 113, 113, 0.35); }
.node-icon { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 10px; color: var(--cyan); background: color-mix(in srgb, var(--cyan) 14%, transparent); }
.node-row.offline .node-icon { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); }
.node-info { flex: 1; min-width: 0; }
.node-info strong { display: block; font-size: 12px; }
.node-info small { display: block; color: var(--muted); font-size: 10px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dash-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--muted);
  font-size: 9px;
  letter-spacing: 0.08em;
}
.dash-footer strong { color: var(--text); }

@media (max-width: 1180px) {
  .dash-columns { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .dash-shell { grid-template-columns: 1fr; }
  .dash-rail {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    padding: 10px;
  }
  .rail-title, .rail-meta { display: none; }
  .rail-link { flex-shrink: 0; white-space: nowrap; }
}

.drawer-backdrop { position: fixed; inset: 0; z-index: 39; background: rgba(2, 6, 16, .52); backdrop-filter: blur(2px); }
.project-drawer {
  position: fixed; z-index: 40; top: 0; right: 0; width: min(452px, 96vw); height: 100vh; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: -30px 0 90px rgba(0, 0, 0, .4);
  transform: translateX(102%); transition: transform .25s ease;
}
.project-drawer.open { transform: translateX(0); }
.drawer-close {
  position: absolute; right: 14px; top: 14px; z-index: 2; width: 32px; height: 32px;
  border: 1px solid rgba(255, 255, 255, .16); border-radius: 7px; cursor: pointer;
  background: rgba(5, 5, 5, .55); backdrop-filter: blur(4px); color: #e8e8ec; font-size: 19px;
}
.drawer-body { padding: 0 26px 20px; }

/* The portrait is the character's own art, keyed to the sprite walking the map,
   so the card reads as that villager's status screen and not a generic panel. */
.status-portrait {
  position: relative;
  height: clamp(250px, 42vh, 420px);
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.portrait-art {
  width: 100%; height: 100%; object-fit: cover; object-position: 50% 12%; display: block;
  opacity: 0; transition: opacity .18s ease;
}
.portrait-art.ready { opacity: 1; }
.portrait-frame {
  /* Above the name plate, so the lower bracket lands on the dark gradient next to
     the text instead of being buried under it. */
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .1), inset 0 0 70px rgba(0, 0, 0, .5);
}
/* Two corner brackets: the cheapest way to make a rectangle read as a game frame. */
.portrait-frame::before, .portrait-frame::after {
  content: ""; position: absolute; width: 17px; height: 17px; border: 2px solid var(--cyan); opacity: .85;
}
.portrait-frame::before { top: 9px; left: 9px; border-right: 0; border-bottom: 0; }
.portrait-frame::after { right: 9px; bottom: 9px; border-left: 0; border-top: 0; }
.portrait-plate {
  position: absolute; inset: auto 0 0 0; display: flex; align-items: flex-end; gap: 14px;
  padding: 40px 22px 18px;
  background: linear-gradient(to top, rgba(5, 5, 5, .95) 26%, rgba(5, 5, 5, .7) 58%, transparent);
}
.plate-text { min-width: 0; }
/* The dot sprite next to the portrait is the tie-back to the map: same character,
   same art the player just clicked on. */
.drawer-avatar {
  --accent: var(--cyan);
  flex: 0 0 auto;
  width: 52px;
  height: 58px;
  display: grid;
  place-items: end center;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: 5px;
  background: rgba(5, 5, 5, .55);
  font-size: 21px;
  font-weight: 800;
  color: var(--accent);
  overflow: hidden;
}
/* 1:1 with the sprite's own pixels. Any other width makes pixelated rendering
   duplicate some columns and not others, which shows as a wobbly outline. */
.drawer-avatar img {
  width: 44px;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.drawer-nickname {
  margin: 3px 0 0;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.plate-text h2 { margin: 7px 0 3px; font-size: 21px; text-shadow: 0 2px 12px rgba(0, 0, 0, .75); }
.plate-text p { margin: 0; color: #c6c6cf; font-size: 11px; }

.status-gauges { display: grid; gap: 11px; padding: 20px 0 3px; }
.gauge-row { display: grid; grid-template-columns: 60px 1fr auto; gap: 11px; align-items: center; }
.gauge-label { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.gauge-track {
  position: relative; height: 13px; border: 1px solid var(--line); border-radius: 3px;
  background: rgba(255, 255, 255, .035); overflow: hidden;
}
/* Notches over both the filled and empty part, so the meter stays chunky at any width. */
.gauge-track::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(90deg, rgba(5, 5, 5, .62) 0 2px, transparent 2px 10px);
}
.gauge-fill {
  display: block; height: 100%; background: var(--gauge-color, var(--cyan));
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, .16), inset 0 -4px 0 rgba(0, 0, 0, .2);
  transition: width .3s ease;
}
.gauge-value { font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 66px; text-align: right; }

.stat-sheet { margin: 16px 0 0; display: grid; gap: 8px; }
.stat-sheet > div { display: flex; align-items: baseline; gap: 9px; }
.stat-sheet dt {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 9px;
  color: var(--muted); font-size: 9px; letter-spacing: .13em; white-space: nowrap;
}
.stat-sheet dt::after { content: ""; flex: 1; border-bottom: 1px dotted rgba(255, 255, 255, .17); }
.stat-sheet dd {
  margin: 0; max-width: 60%; font-size: 11px; font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-drawer section { border-top: 1px solid var(--line); padding: 21px 0; }
.project-drawer h3 { margin: 0; color: var(--muted); font-size: 9px; letter-spacing: .17em; }
.section-title { display: flex; align-items: center; justify-content: space-between; }
.section-title span { color: var(--muted); font-size: 9px; }
.metric-bars { margin-top: 17px; display: grid; gap: 11px; }
.metric-row { display: grid; grid-template-columns: 112px 1fr 28px; gap: 10px; align-items: center; }
.metric-row label { color: #aebbd0; font-size: 10px; text-transform: uppercase; }
.bar-track { height: 5px; border-radius: 4px; background: rgba(129, 144, 170, .13); overflow: hidden; }
.bar-fill { display: block; height: 100%; min-width: 0; border-radius: inherit; background: var(--bar-color, var(--cyan)); transition: width 0.3s ease; }
.metric-row strong { text-align: right; font-size: 11px; font-variant-numeric: tabular-nums; }
.project-drawer footer { color: #536079; font-size: 9px; overflow-wrap: anywhere; padding: 10px 0 20px; }

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    height: auto;
    row-gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .brand { grid-row: 1; }
  .connection { grid-row: 1; }
  .view-switcher { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  /* Three views no longer fit a phone row at full padding, so the labels get the
     space and the icons keep their own line-free box. */
  .view-switcher .view-button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 6px;
    white-space: nowrap;
  }
}

@media (max-width: 620px) {
  main { padding-inline: 12px; }
  .topbar { padding-inline: 15px; }
  .connection time { display: none; }
  .village-toolbar, .dash-heading { align-items: flex-start; gap: 17px; flex-direction: column; }
  .map-legend { display: none; }
  .search-box { width: 100%; }
  .drawer-body { padding: 0 18px 18px; }
}
