* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.app-shell-v2 {
  width: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100dvh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px 14px;
  color: #ffffff;
  background: var(--nav);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.32) transparent;
}

.brand-block {
  display: grid;
  gap: 3px;
  padding: 8px 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-block strong {
  font-size: 20px;
}

.brand-block span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
}

.nav-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.side-nav-scroll {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.nav-stack-secondary {
  margin-top: 0;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.side-nav-footer {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
}

.side-nav-meta {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  color: rgba(255, 255, 255, 0.68);
  font-size: 12px;
}

.side-nav-meta span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace-v2 {
  width: 100%;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 10px 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
}

.topbar > div:first-child {
  display: grid;
  gap: 1px;
}

.topbar span {
  color: var(--muted);
  font-size: 13px;
}

.topbar .version-chip {
  vertical-align: middle;
}

.version-chip {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 999px;
  color: var(--primary);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.side-nav .version-chip {
  color: #dbeafe;
  border-color: rgba(219, 234, 254, 0.28);
  background: rgba(255, 255, 255, 0.12);
}

.identity-chip {
  max-width: 42vw;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-v2 {
  width: min(1180px, calc(100vw - 240px - 44px));
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px;
}

.screen {
  display: grid;
  gap: 18px;
}

.screen-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.screen-head h1,
.screen h1,
.screen h2 {
  margin: 0;
  letter-spacing: 0;
}

.screen-head h1 {
  font-size: 24px;
}

.screen-head p {
  margin: 3px 0 0;
  color: var(--muted);
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-row h2 {
  font-size: 18px;
}

.bottom-nav {
  display: none;
}

@media (max-width: 1023px) {
  .app-shell-v2 {
    display: block;
  }

  .side-nav {
    display: none;
  }
}

@media (max-width: 767px) {
  body {
    overflow-x: hidden;
  }

  .topbar {
    min-height: 58px;
    padding: 9px 14px;
  }

  .topbar strong {
    font-size: 16px;
  }

  .topbar span {
    font-size: 12px;
  }

  .identity-chip {
    max-width: 38vw;
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
  }

  .main-v2 {
    width: 100%;
    max-width: none;
    padding: 14px 14px 92px;
  }

  .screen {
    gap: 14px;
  }

  .screen-head {
    align-items: flex-start;
  }

  .screen-head h1 {
    font-size: 21px;
  }

  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(56px, 1fr));
    gap: 4px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line);
    box-shadow: 0 -8px 24px rgba(16, 24, 40, 0.08);
  }

  .bottom-nav .nav-item {
    min-height: 44px;
    padding: 6px 4px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
  }

  .bottom-nav .nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
  }

  .bottom-nav .nav-dot {
    display: none;
  }
}
