/* The frame of every signed-in page: menu on the left, status line on top, page below. */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

/* --- Menu --- */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

/* The fixed top and bottom of the menu cast a shadow onto the part that scrolls between
   them, which so appears set back. */
.brand,
.sidebar-foot {
  position: relative;
  z-index: 1;
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  flex: none;
  height: var(--statusbar-height);
  padding: 0 1.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 5px 7px -3px var(--menu-shadow);
}

.nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem;
  overflow-y: auto;
  background: var(--surface-sunken);
}

/* A heading of the menu; a click opens and closes what is under it. */
.nav-group {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  justify-content: flex-start;
  width: 100%;
  min-height: 0;
  margin: 0.75rem 0 0.15rem;
  padding: 0.2rem 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 0;
}

.nav-group:hover:not(:disabled) {
  color: var(--text);
  background: transparent;
}

.nav-group .icon {
  width: 0.85rem;
  height: 0.85rem;
}

.nav-group[aria-expanded="false"] .icon {
  transform: rotate(-90deg);
}

.nav-items {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-items[hidden] {
  display: none;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.5rem;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius);
}

.nav a span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.nav a:hover {
  background: var(--row-hover);
}

.nav a[aria-current="page"] {
  font-weight: 600;
  color: var(--on-accent);
  background: var(--accent);
}

/* The edge of the menu: dragging it changes the width. */
.sidebar-resize {
  position: absolute;
  top: 0;
  right: -3px;
  bottom: 0;
  z-index: 2;
  width: 6px;
  cursor: col-resize;
}

.sidebar-resize:hover,
.sidebar-resize:focus-visible,
.sidebar-resize.active {
  background: var(--accent);
  opacity: 0.5;
}

/* Fixed at the bottom of the menu: who is signed in, the version, then mode switch and sign-out. */
.sidebar-foot {
  flex: none;
  padding: 0.75rem 1.25rem 1rem;
  border-top: 1px solid var(--border);
  box-shadow: 0 -5px 7px -3px var(--menu-shadow);
}

.account-name {
  display: block;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.account-name:hover {
  text-decoration: underline;
}

.account-version {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.account-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

/* --- Status line: page title, state, and the page's actions at the top right --- */
.main {
  min-width: 0;
}

.statusbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 1rem;
  min-height: var(--statusbar-height);
  padding: 0.5rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.statusbar-icon {
  display: inline-flex;
  margin-right: -0.5rem;
  color: var(--text-muted);
}

.statusbar-icon:empty {
  display: none;
}

.statusbar-icon .icon {
  width: 1.3rem;
  height: 1.3rem;
}

.statusbar-info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  font-size: 0.87rem;
  color: var(--text-muted);
}

.statusbar-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.menu-button {
  display: none;
}

/* Tables use the width there is, however far the page is zoomed out; forms limit
   themselves. */
.content {
  padding: 1.25rem 1.5rem 3rem;
}

.backdrop {
  display: none;
}

/* --- Narrow screens: the menu slides over the page instead of sitting beside it --- */
@media (max-width: 800px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  /* The menu lies over the page here; its width is not for dragging. */
  .sidebar-resize {
    display: none;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: none;
    width: min(17rem, 85vw);
    box-shadow: var(--shadow);
  }

  .shell.menu-open .sidebar {
    display: flex;
  }

  .shell.menu-open .backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    background: var(--backdrop);
  }

  .menu-button {
    display: inline-flex;
  }

  .statusbar {
    padding: 0.5rem 0.75rem;
  }

  .content {
    padding: 0.75rem;
  }
}

/* --- Sign-in page --- */
.login {
  display: grid;
  place-items: start center;
  min-height: 100vh;
  padding: 12vh 1rem 2rem;
}

.login-box {
  width: 100%;
  max-width: 22rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-box h1 {
  margin-bottom: 1rem;
  font-size: 1.4rem;
}
