/* DVeMesh application shell and product views */

.app-body {
  min-height: 100dvh;
  background:
    radial-gradient(720px 380px at 12% 0%, rgba(79, 209, 197, 0.045), transparent 58%),
    radial-gradient(560px 320px at 100% 100%, rgba(110, 168, 255, 0.03), transparent 55%),
    var(--bg);
}
.app-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.028) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 50% 30%, #000 18%, transparent 78%);
}

.app-header { position: sticky; z-index: 40; }
.app-header-start {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.app-user {
  color: var(--text-dim);
  font-size: 13px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  min-height: calc(100dvh - var(--nav));
}

.sidebar {
  border-right: 1px solid var(--border);
  padding: 16px 12px 24px;
  background: rgba(12, 16, 22, 0.72);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-group + .sidebar-group {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.sidebar a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  padding: 8px 12px;
  min-height: 44px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
}
.sidebar a .label { min-width: 0; }
.sidebar a.active {
  background: rgba(79, 209, 197, 0.1);
  color: var(--text);
}
.sidebar a.active::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-left: -4px;
}
.sidebar a:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.sidebar-backdrop {
  display: none;
}

.main {
  padding: 28px 32px 48px;
  min-width: 0;
}
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -0.03em; font-weight: 650; }

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0 8px;
}

.health-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-mute);
  font-size: 13px;
  margin: 8px 0 0;
}

.topo {
  height: min(620px, 70vh);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(37, 48, 64, 0.45) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(37, 48, 64, 0.45) 1px, transparent 1px) 0 0 / 28px 28px,
    rgba(7, 9, 13, 0.6);
  position: relative;
  overflow: hidden;
  touch-action: none;
}
.topo svg { width: 100%; height: 100%; display: block; }
.topo-node {
  cursor: pointer;
}
.topo-node rect {
  fill: var(--surface);
  stroke: var(--border-strong);
}
.topo-node text { fill: var(--text); font-size: 12px; font-family: var(--font); }
.topo-node .sub { fill: var(--text-mute); font-size: 10px; font-family: var(--mono); }
.topo-edge { stroke: rgba(79, 209, 197, 0.35); stroke-width: 1.5; fill: none; }
.topo-panel {
  position: absolute;
  right: 12px;
  top: 12px;
  width: min(260px, calc(100% - 24px));
  z-index: 2;
}

.wizard { display: grid; gap: 16px; }
.steps { display: flex; gap: 8px; flex-wrap: wrap; }
.step {
  padding: 6px 10px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text-mute);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.step.current { color: var(--text); border-color: var(--accent); }
.step.done { color: var(--ok); border-color: rgba(61, 207, 122, 0.35); }

.secret-box {
  font-family: var(--mono);
  background: #0b1016;
  border: 1px solid var(--border-strong);
  padding: 14px;
  border-radius: 8px;
  word-break: break-all;
  font-size: 13px;
}

.wait-state {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
}
.wait-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(79, 209, 197, 0.45);
  animation: wait-pulse 1.6s ease-out infinite;
}
@keyframes wait-pulse {
  0% { box-shadow: 0 0 0 0 rgba(79, 209, 197, 0.45); }
  70% { box-shadow: 0 0 0 10px rgba(79, 209, 197, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 209, 197, 0); }
}

.bottom-nav {
  display: none;
}

.menu-toggle { display: none; }

@media (max-width: 1023px) {
  .menu-toggle { display: inline-flex; }
  .app-shell { grid-template-columns: var(--rail) 1fr; }
  .sidebar .label { display: none; }
  .sidebar a { justify-content: center; padding: 8px; }
  .sidebar a.active::before { display: none; }
  .sidebar { padding: 12px 8px; }
  .main { padding: 20px 18px 40px; }
}

@media (min-width: 768px) {
  .topo-list { display: none; }
}

@media (max-width: 767px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    z-index: 45;
    inset: var(--nav) auto 0 0;
    width: min(280px, 86vw);
    transform: translateX(-105%);
    transition: transform 180ms ease;
    border-right: 1px solid var(--border);
    background: #0c1016;
  }
  .sidebar .label { display: inline; }
  .sidebar a { justify-content: flex-start; padding: 8px 12px; }
  .sidebar a.active::before { display: block; }
  body.nav-open .sidebar { transform: none; }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--nav) 0 0 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 44;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }
  body.nav-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  .main { padding: 16px 12px calc(var(--bottom-nav) + 20px); }
  .page-head { flex-direction: column; }
  .page-head h1 { font-size: 24px; }
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 35;
    height: var(--bottom-nav);
    background: rgba(8, 11, 16, 0.94);
    border-top: 1px solid var(--border);
    padding: 0 4px env(safe-area-inset-bottom);
  }
  .bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-mute);
    text-decoration: none;
    font-size: 11px;
    min-height: 44px;
  }
  .bottom-nav a.active { color: var(--accent); }
  .app-user { display: none; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .object-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .topo { height: min(520px, 62vh); }
  body.nav-open .app-shell { grid-template-columns: var(--sidebar) 1fr; }
  body.nav-open .sidebar .label { display: inline; }
  body.nav-open .sidebar a { justify-content: flex-start; padding: 8px 12px; }
  body.nav-open .sidebar a.active::before { display: block; }
}

@media (max-width: 479px) {
  .grid-stats { grid-template-columns: 1fr 1fr; }
  .stat strong { font-size: 22px; }
  .object-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-backdrop, .wait-dot { transition: none; animation: none; }
}
