/* Application shell: sidebar navigation + topbar + content area. */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  grid-template-areas:
    "brand topbar"
    "nav main";
  height: 100vh;
}

.shell.collapsed {
  grid-template-columns: var(--sidebar-width-collapsed) minmax(0, 1fr);
}

/* Keyboard shortcut into the main content — hidden until focused. */
.skip-link {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus-visible {
  width: auto;
  height: auto;
  padding: var(--space-2) var(--space-4);
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
  top: var(--space-3);
  left: var(--space-3);
  z-index: 100;
  background: var(--blue-600);
  color: #fff;
  border-radius: var(--radius-m);
  font-size: 13px;
}

.shell-brand {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  background: var(--text-1);
  color: #fff;
  font-weight: 650;
  font-size: 14px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
}

.shell-brand .brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-m);
  background: var(--blue-500);
  color: #fff;
  flex: none;
}

.shell-brand .brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell.collapsed .brand-name {
  display: none;
}

.shell-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-4);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  min-width: 0;
}

.shell-topbar .topbar-search {
  flex: 1 1 320px;
  max-width: 520px;
  min-width: 120px;
  position: relative;
}

.shell-topbar .topbar-search input {
  width: 100%;
  padding: 6px 10px 6px 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--bg-0);
  font-size: 13px;
}

.shell-topbar .topbar-search input:focus {
  background: var(--bg-1);
  border-color: var(--blue-500);
  outline: none;
  box-shadow: 0 0 0 2px var(--blue-100);
}

.shell-topbar .topbar-search .search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  display: inline-flex;
}

.shell-topbar .topbar-run {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.shell-topbar .topbar-run label {
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.shell-topbar .topbar-run select {
  max-width: 240px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--bg-1);
  font-family: var(--font-mono);
  font-size: 12px;
}

.shell-nav {
  grid-area: nav;
  background: var(--text-1);
  color: #cbd5e1;
  padding: var(--space-3) var(--space-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shell-nav .nav-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: 7px 10px;
  margin-bottom: var(--space-2);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-m);
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.shell-nav .nav-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.shell-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px 10px;
  border-radius: var(--radius-m);
  color: inherit;
  font-size: 13px;
  white-space: nowrap;
  transition: background var(--transition-fast);
}

.shell-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}

.shell-nav a.active {
  background: var(--blue-600);
  color: #fff;
  font-weight: 550;
}

.shell-nav a .nav-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.shell.collapsed .shell-nav a {
  justify-content: center;
}

.shell.collapsed .shell-nav a .nav-label {
  display: none;
}

.shell-nav .nav-footer {
  margin-top: auto;
  padding: var(--space-2) 10px;
  font-size: 11px;
  color: #7d8aa0;
}

.shell.collapsed .nav-footer {
  display: none;
}

.shell-main {
  grid-area: main;
  overflow-y: auto;
  padding: var(--space-5) var(--space-6);
  min-width: 0;
}

.page {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.page-header {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.page-header .page-title-block {
  min-width: 0;
  flex: 1 1 auto;
}

.page-header h1 {
  font-size: 19px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.page-header .page-subtitle {
  margin-top: 2px;
  color: var(--text-2);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.page-header .page-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  align-items: center;
}

.breadcrumbs {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.breadcrumbs a {
  color: var(--text-2);
}

@media (max-width: 900px) {
  .shell,
  .shell.collapsed {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) auto auto minmax(0, 1fr);
    grid-template-areas:
      "brand"
      "topbar"
      "nav"
      "main";
  }

  .shell-brand .brand-name {
    display: inline;
  }

  .shell-topbar {
    flex-wrap: wrap;
    row-gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }

  .shell-topbar .topbar-search {
    flex: 1 1 100%;
    max-width: none;
  }

  .shell-topbar .topbar-run {
    margin-left: 0;
  }

  .shell-topbar .topbar-run select {
    max-width: 150px;
  }

  .shell-nav {
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: var(--space-2);
    /* Edge fades hint that the nav scrolls horizontally. */
    background:
      linear-gradient(to right, var(--text-1) 30%, transparent),
      linear-gradient(to left, var(--text-1) 30%, transparent),
      radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.4), transparent),
      radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.4), transparent);
    background-repeat: no-repeat;
    background-size:
      32px 100%,
      32px 100%,
      10px 100%,
      10px 100%;
    background-attachment: local, local, scroll, scroll;
  }

  .shell-nav .nav-toggle,
  .shell-nav .nav-footer {
    display: none;
  }

  .shell-nav a {
    padding: 6px 10px;
  }

  .shell-nav a .nav-label,
  .shell.collapsed .shell-nav a .nav-label {
    display: inline;
  }

  .shell-main {
    padding: var(--space-4);
  }
}
