.category-order-toolbar {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
  padding: 0 14px 8px;
}

.category-order-open {
  min-height: 44px;
  max-width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--primary-light);
  border-radius: 9px;
  background: var(--primary-bg);
  color: var(--primary);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: normal;
  cursor: pointer;
}

.category-order-open:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

.category-order-dialog {
  position: fixed;
  inset: 0;
  width: min(520px, calc(100vw - 24px));
  max-width: none;
  height: fit-content;
  max-height: min(718px, calc(100dvh - 26px));
  margin: auto;
  padding: 0;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--gray-900);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.category-order-dialog::backdrop { background: rgba(15, 23, 42, .56); }

.category-order-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-height: min(720px, calc(100dvh - 24px));
}

.category-order-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--gray-200);
  flex: 0 0 auto;
}

.category-order-header > div { min-width: 0; flex: 1; }
.category-order-header h2 { font-size: 17px; line-height: 1.4; overflow-wrap: anywhere; }
.category-order-header p { margin-top: 5px; color: var(--gray-500); font-size: 12px; line-height: 1.5; }
.category-order-header p span { display: inline-block; margin-right: .25em; }

.category-order-dialog button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.category-order-dialog button:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

.category-order-dialog button:disabled { cursor: default; opacity: .42; }

.category-order-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: 9px;
  background: var(--gray-50);
  color: var(--gray-700);
  font-size: 25px !important;
  line-height: 1;
}

.category-order-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 12px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.category-order-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 56px;
  padding: 5px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.category-order-row.is-dragging {
  border-color: var(--primary-light);
  background: var(--primary-bg);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.category-order-handle,
.category-order-up,
.category-order-down {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--gray-50);
  color: var(--gray-700);
}

.category-order-handle {
  flex: 0 0 44px;
  touch-action: none;
  cursor: grab !important;
  color: var(--primary);
  font-size: 23px !important;
  line-height: 1;
}

.category-order-handle:active { cursor: grabbing !important; }
.category-order-position { display: none; }

.category-order-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
  font-weight: 700;
}

.category-order-row-actions { display: flex; flex: 0 0 auto; gap: 4px; }
.category-order-up, .category-order-down { padding: 0 5px; font-size: 12px !important; }

.category-order-live {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.category-order-footer {
  flex: 0 0 auto;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--gray-200);
  background: var(--white);
}

.category-order-error {
  margin: 0 0 8px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.category-order-error[hidden] { display: none; }
.category-order-actions { display: flex; justify-content: space-between; gap: 12px; }
.category-order-cancel, .category-order-save {
  min-height: 44px;
  min-width: 96px;
  padding: 0 16px;
  border-radius: 9px;
  font-weight: 700 !important;
}

.category-order-cancel { border: 1px solid var(--gray-300); background: var(--white); color: var(--gray-700); }
.category-order-save { border: 1px solid var(--primary); background: var(--primary); color: var(--white); }

@media (max-width: 359px) {
  .category-order-list { padding: 8px; }
  .category-order-row { gap: 4px; padding: 4px; }
  .category-order-up, .category-order-down { min-width: 44px; padding: 0 2px; }
}
