/* Keep the five quick-action buttons and the full sidebar accessible on every viewport. */
.app-shell {
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.rail {
  height: 100vh;
  overflow: visible;
  z-index: 30;
}

.rail-action {
  display: grid;
  place-items: center;
  flex: 0 0 40px;
}

.rail-action:hover,
.rail-action.active {
  background: #edf1f6;
}

.sidebar {
  height: 100vh;
  min-height: 0;
  overflow-y: auto;
  overflow-x: visible;
  scrollbar-gutter: stable;
}

.sidebar nav {
  padding-bottom: 78px;
}

/* The fallback sidebar uses the same tidy accordion behavior as the quick menu. */
.sidebar .subnav[hidden] {
  display: none;
}

.sidebar .nav-row.expanded i {
  transition: transform .16s ease;
}

.sidebar .nav-row.expanded.is-open i {
  transform: rotate(180deg);
}

main {
  height: 100vh;
  overflow: auto;
}

.collapse {
  position: fixed;
  left: 234px;
  right: auto;
  bottom: 24px;
  z-index: 40;
}

.compact .collapse {
  left: 33px;
  right: auto;
}

@media (max-width: 900px) {
  .rail { display: flex !important; }
}

.filters .order-filter.selected {
  border-color: var(--blue);
  color: var(--blue);
  background: #edf3ff;
}

.quick-menu[hidden] {
  display: none;
}

.quick-menu {
  position: fixed;
  z-index: 70;
  top: 10px;
  bottom: 10px;
  left: 61px;
  width: min(274px, calc(100vw - 72px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 42px #15233c2b;
  padding: 11px;
}

.quick-menu header {
  display: flex;
  align-items: center;
  padding: 8px 8px 12px;
  border-bottom: 1px solid var(--line);
}

.quick-menu header small {
  color: #8490a0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
}

.quick-menu header h3 {
  margin: 3px 0 0;
  font-size: 18px;
}

.quick-menu header button {
  width: 34px;
  height: 34px;
  margin-left: auto;
  border: 0;
  border-radius: 8px;
  background: #f2f5f9;
  color: #3f4855;
  font-size: 24px;
  cursor: pointer;
}

.quick-menu nav {
  padding: 10px 0 0;
}

.quick-menu-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  gap: 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 0 10px;
  color: var(--text);
  font: 500 14px "DM Sans", sans-serif;
  text-align: left;
  cursor: pointer;
}

.quick-menu-item:hover {
  background: #edf3ff;
  color: var(--blue);
}

.quick-menu-item span {
  width: 21px;
  text-align: center;
  font-size: 17px;
}

.quick-menu-item b {
  margin-left: auto;
  color: #9aa4b3;
  font-size: 19px;
}

/* Portal-style icon rail and its five expanded menus. */
.rail-action {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  color: #202124;
}

.rail-icon,
.quick-icon-wrap {
  display: grid;
  place-items: center;
}

.rail-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-action.active {
  background: #f3f6fa;
  box-shadow: 0 0 0 3px #8ac6fb;
}

.quick-menu {
  top: 0;
  bottom: 0;
  left: 52px;
  width: min(238px, calc(100vw - 52px));
  border: 0;
  border-left: 1px solid #e7e9ee;
  border-right: 1px solid #e7e9ee;
  border-radius: 0;
  box-shadow: 3px 0 8px #1822370c;
  padding: 10px 7px;
}

.quick-menu nav {
  padding: 0;
}

.quick-menu-row {
  margin: 0 0 2px;
}

.quick-menu-item {
  min-height: 54px;
  gap: 12px;
  border-radius: 8px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
}

.quick-menu-item:hover,
.quick-menu-item.is-expanded,
.quick-menu-item.is-current {
  background: #f0f5fb;
  color: #111;
}

.quick-icon-wrap {
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
}

.quick-icon {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.etsy-icon {
  font: 24px Georgia, serif;
  line-height: 1;
}

.quick-chevron {
  color: #14171b !important;
  font-size: 18px !important;
  transition: transform .16s ease;
}

.quick-menu-item.is-expanded .quick-chevron {
  transform: rotate(180deg);
}

.quick-submenu {
  display: grid;
  gap: 4px;
  margin: -1px 10px 6px 46px;
  padding: 5px 0 5px 10px;
  border-left: 2px solid #e6edf5;
}

.quick-submenu[hidden] {
  display: none;
}

.quick-submenu button {
  min-height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0 10px;
  color: #586373;
  font: 500 13px inherit;
  text-align: left;
  cursor: pointer;
}

.quick-submenu button:hover {
  background: #edf3ff;
  color: var(--blue);
}

.quick-submenu button.is-current {
  background: #edf3ff;
  color: var(--blue);
}

/* The active outer-icon menu is a persistent sidebar, not a temporary popup. */
.sidebar > .quick-menu {
  position: absolute;
  z-index: 10;
  inset: 61px 0 0;
  width: auto;
  min-width: 0;
  height: auto;
  overflow-y: auto;
  overflow-x: hidden;
  border: 0;
  border-right: 1px solid #e7e9ee;
  border-radius: 0;
  background: #fff;
  box-shadow: none;
}

.sidebar > .brand {
  position: relative;
  z-index: 20;
}

.quick-menu .quick-mobile-header,
.mobile-menu-scrim {
  display: none;
}

/* A true mobile drawer: the five rail icons remain visible and open their
   corresponding menu, while the workspace keeps its full usable width. */
@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .sidebar {
    display: block;
    position: fixed;
    z-index: 80;
    inset: 0 auto 0 52px;
    width: min(288px, calc(100vw - 52px));
    height: 100dvh;
    border-right: 1px solid #e7e9ee;
    box-shadow: 14px 0 30px #1720332b;
    opacity: 0;
    pointer-events: none;
    transform: translateX(-18px);
    transition: opacity .18s ease, transform .18s ease;
    visibility: hidden;
  }

  .app-shell.mobile-menu-open .sidebar {
    opacity: 1;
    pointer-events: auto;
    transform: none;
    visibility: visible;
  }

  .sidebar > .brand,
  .sidebar > nav,
  .collapse {
    display: none;
  }

  .sidebar > .quick-menu {
    position: static;
    display: block;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 8px calc(20px + env(safe-area-inset-bottom));
    border: 0;
  }

  .quick-menu .quick-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 54px;
    margin: -2px 2px 8px;
    padding: 0 8px 10px;
    border-bottom: 1px solid #e8ecf1;
  }

  .quick-mobile-header small,
  .quick-mobile-header strong {
    display: block;
  }

  .quick-mobile-header small {
    color: #7b8795;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
  }

  .quick-mobile-header strong {
    margin-top: 2px;
    font-size: 17px;
  }

  .quick-mobile-header button {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    border: 0;
    border-radius: 9px;
    background: #f1f4f8;
    color: #303846;
    font-size: 24px;
    cursor: pointer;
  }

  .mobile-menu-scrim:not([hidden]) {
    display: block;
    position: fixed;
    z-index: 70;
    inset: 0 0 0 52px;
    border: 0;
    background: rgb(18 29 45 / 30%);
    cursor: pointer;
  }
}

@media (max-width: 520px) {
  .rail {
    gap: 14px;
    padding-top: 9px;
  }

  .rail-logo {
    height: 38px;
    font-size: 29px;
  }

  .sidebar {
    width: min(286px, calc(100vw - 48px));
    inset-inline-start: 48px;
  }

  .mobile-menu-scrim:not([hidden]) {
    inset-inline-start: 48px;
  }

  .app-shell {
    grid-template-columns: 48px minmax(0, 1fr);
  }

  .rail-action {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
  }

  .topbar {
    height: 58px;
    gap: 8px;
    padding: 0 12px;
  }

  .topbar h1 {
    font-size: 17px;
  }

  .topbar h2 {
    margin-top: 1px;
    font-size: 13px;
  }

  .top-actions .icon-button {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .content,
  .workspace {
    padding: 12px;
  }

  .search-row,
  .filters,
  .workspace-head,
  .listing-head,
  .extension-header,
  .tracking-title,
  .log-head,
  .check-title {
    flex-wrap: wrap;
  }

  .search-row {
    gap: 8px;
  }

  .search-row input,
  .mapping-tools input,
  .config-tools input {
    width: 100%;
  }

  .search-row .total,
  .workspace-head .push,
  .listing-head .push,
  .extension-header .push,
  .tracking-title .push,
  .log-head .push,
  .check-title .push {
    margin-left: 0;
  }

  .filters {
    gap: 6px;
    margin-bottom: 12px;
  }

  .filters span {
    display: none;
  }

  .filters button {
    height: 36px;
    padding: 0 10px;
    font-size: 13px;
  }

  .card-grid,
  .listing-metrics,
  .client-metrics,
  .auto-grid {
    grid-template-columns: 1fr;
  }

  .home-welcome,
  .auto-title,
  .auto-task {
    flex-wrap: wrap;
  }

  .auto-title {
    min-height: 64px;
    height: auto;
    margin: -12px -12px 14px;
    padding: 12px;
  }

  .auto-title .push,
  .auto-tabs {
    margin-left: 0;
  }

  .dialog {
    width: min(94vw, 550px);
    max-height: 88dvh;
    overflow-y: auto;
    padding: 18px;
  }

  .dialog menu {
    flex-wrap: wrap;
  }

  .floating {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
  }
}
